From 23c07fbd8556e2f93dd92841a8828ad810f28ea3 Mon Sep 17 00:00:00 2001 From: Johnny Sequeira Date: Thu, 24 Oct 2024 12:18:33 -0600 Subject: [PATCH] Adding suggestion on code styling and some air --- libqfieldsync/offline_converter.py | 6 ++---- libqfieldsync/offliners.py | 4 +++- libqfieldsync/utils/qgis.py | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libqfieldsync/offline_converter.py b/libqfieldsync/offline_converter.py index 8ccbc8d..e74c53c 100644 --- a/libqfieldsync/offline_converter.py +++ b/libqfieldsync/offline_converter.py @@ -92,7 +92,7 @@ def __init__( export_type: ExportType = ExportType.Cable, create_basemap: bool = True, dirs_to_copy: Optional[Dict[str, bool]] = None, - export_title: Optional[str] = None, + export_title: str = "", ): super(OfflineConverter, self).__init__(parent=None) self.__max_task_progress = 0 @@ -276,9 +276,7 @@ def _convert(self, project: QgsProject) -> None: elif layer_action == SyncAction.REMOVE: project.removeMapLayer(layer) - export_project_filename = self._export_filename.parent.joinpath( - f"{self._export_filename.stem}.qgs" - ) + export_project_filename = self._export_filename # save the original project path self.project_configuration.original_project_path = str(self.original_filename) diff --git a/libqfieldsync/offliners.py b/libqfieldsync/offliners.py index 3986588..7867fb2 100644 --- a/libqfieldsync/offliners.py +++ b/libqfieldsync/offliners.py @@ -460,12 +460,14 @@ class LayerInfo(NamedTuple): project_title = exported_project_title else: project_title = project.title() + if not project_title: project_title = QFileInfo(project.fileName()).baseName() + project_title += f"{project_title} (offline)" - project.setTitle(project_title) project.setTitle(project_title) + project.writeEntry( PROJECT_ENTRY_SCOPE_OFFLINE, PROJECT_ENTRY_KEY_OFFLINE_DB_PATH, diff --git a/libqfieldsync/utils/qgis.py b/libqfieldsync/utils/qgis.py index 890a646..34b758e 100644 --- a/libqfieldsync/utils/qgis.py +++ b/libqfieldsync/utils/qgis.py @@ -48,9 +48,7 @@ def open_project(filename: str, filename_to_read: Optional[str] = None) -> bool: return is_success -def make_temp_qgis_file( - project: QgsProject, -) -> str: +def make_temp_qgis_file(project: QgsProject) -> str: project_backup_dir = tempfile.mkdtemp() original_filename = project.fileName() backup_filename = os.path.join(project_backup_dir, f"{project.baseName()}.qgs")