From 9b6f6b2cd6359d710622c2167c7deb4504216927 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 28 Feb 2026 07:44:52 +0100 Subject: [PATCH] sharing/csv separator and properties overlay --- radicale/sharing/__init__.py | 3 ++- radicale/sharing/csv.py | 13 ++++++++----- radicale/sharing/files.py | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/radicale/sharing/__init__.py b/radicale/sharing/__init__.py index 782ba8ad..76ed8e24 100644 --- a/radicale/sharing/__init__.py +++ b/radicale/sharing/__init__.py @@ -958,7 +958,8 @@ class BaseSharing: if output_format == "csv": writer.writeheader() for entry in answer['Content']: - writer.writerow(entry) + # TODO: Argument 1 to "writerow" of "DictWriter" has incompatible type "str"; expected "Mapping[str, Any]" [arg-type] + writer.writerow(entry) # type: ignore[arg-type] if output_format == "csv": answer_array.append(csv.getvalue()) else: diff --git a/radicale/sharing/csv.py b/radicale/sharing/csv.py index e022e646..1723c495 100644 --- a/radicale/sharing/csv.py +++ b/radicale/sharing/csv.py @@ -128,9 +128,9 @@ class Sharing(sharing.BaseSharing): UserShare = row['User'] Permissions = row['Permissions'] Hidden: bool = (row['HiddenByOwner'] or row['HiddenByUser']) - Properties = row['Properties'] - if logger.isEnabledFor(logging.DEBUG): - logger.debug("TRACE/sharing: map %r to %r (Owner=%r User=%r Permissions=%r Hidden=%s Properties=%r)", PathOrToken, PathMapped, Owner, UserShare, Permissions, Hidden, Properties) + Properties: Union[dict, None] = None + if 'Properties' in row: + Properties = row['Properties'] return { "mapped": True, "PathOrToken": PathOrToken, @@ -501,7 +501,7 @@ class Sharing(sharing.BaseSharing): def _create_empty_csv(self, file: str) -> bool: with self._storage.acquire_lock("w", None, path=file): with open(file, 'w', newline='') as csvfile: - writer = csv.DictWriter(csvfile, fieldnames=sharing.DB_FIELDS_V1) + writer = csv.DictWriter(csvfile, fieldnames=sharing.DB_FIELDS_V1, delimiter=';') writer.writeheader() return True @@ -523,7 +523,10 @@ class Sharing(sharing.BaseSharing): # convert txt to bool if self._lines > 0: for fieldname in sharing.DB_FIELDS_V1_BOOL: - row[fieldname] = config._convert_to_bool(row[fieldname]) + try: + row[fieldname] = config._convert_to_bool(row[fieldname]) + except Exception as e: + logger.error("sharing database row error fieldname=%r row=%r error: %r", fieldname, row, e) for fieldname in sharing.DB_FIELDS_V1_INT: row[fieldname] = int(row[fieldname]) # check for duplicates diff --git a/radicale/sharing/files.py b/radicale/sharing/files.py index fc8433bf..40dcb7b2 100644 --- a/radicale/sharing/files.py +++ b/radicale/sharing/files.py @@ -122,7 +122,9 @@ class Sharing(sharing.BaseSharing): UserShare = row['User'] Permissions = row['Permissions'] Hidden: bool = (row['HiddenByOwner'] or row['HiddenByUser']) - Properties = row['Properties'] + Properties: Union[dict, None] = None + if 'Properties' in row: + Properties = row['Properties'] if logger.isEnabledFor(logging.DEBUG): logger.debug("TRACE/sharing: map %r to %r (Owner=%r User=%r Permissions=%r Hidden=%s Properties=%r)", PathOrToken, PathMapped, Owner, UserShare, Permissions, Hidden, Properties) return {