From 3aab6ea07690ce50a9c12f43295e2b9151ad8859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Tveite?= Date: Sat, 29 Aug 2020 15:09:00 +0200 Subject: [PATCH] Fix PEP8 issues (#157) --- resource_sharing/repository_manager.py | 8 ++++---- resource_sharing/resource_handler/base.py | 3 ++- .../resource_handler/checklist_handler.py | 1 - resource_sharing/resource_handler/symbol_handler.py | 8 ++++---- resource_sharing/utilities.py | 12 +++++++++++- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/resource_sharing/repository_manager.py b/resource_sharing/repository_manager.py index 26d26966..17aa9c7b 100644 --- a/resource_sharing/repository_manager.py +++ b/resource_sharing/repository_manager.py @@ -281,20 +281,20 @@ def edit_directory( for installed_collection in installed_old_collections: reg_name = installed_collection['register_name'] is_present = False - for collection in new_collections: + for n_coll in new_collections: # Look for collections that are already present - if collection['register_name'] == reg_name: + if n_coll['register_name'] == reg_name: # Already present is_present = True if old_url == new_url: # Set the status to installed - collection['status'] = COLLECTION_INSTALLED_STATUS + n_coll['status'] = COLLECTION_INSTALLED_STATUS # Keep the collection statistics for key in installed_collection.keys(): if key in ['models', 'processing', 'rscripts', 'style', 'svg', 'symbol', 'expressions']: - collection[key] = installed_collection[key] + n_coll[key] = installed_collection[key] else: # Different repository URLs, so append new_collections.append(installed_collection) diff --git a/resource_sharing/resource_handler/base.py b/resource_sharing/resource_handler/base.py index 26c6e63c..6411b1af 100644 --- a/resource_sharing/resource_handler/base.py +++ b/resource_sharing/resource_handler/base.py @@ -57,7 +57,8 @@ def dir_name(cls): @property def resource_dir(self): """The root of the resource dir from this resource type.""" - resource_dir = local_collection_path(self.collection_id) / self.dir_name() + resource_dir = (local_collection_path(self.collection_id) / + self.dir_name()) return resource_dir def install(self): diff --git a/resource_sharing/resource_handler/checklist_handler.py b/resource_sharing/resource_handler/checklist_handler.py index 62c6120a..6ecfde7c 100644 --- a/resource_sharing/resource_handler/checklist_handler.py +++ b/resource_sharing/resource_handler/checklist_handler.py @@ -61,4 +61,3 @@ def uninstall(self): self.checklists_directory.rmdir() else: LOGGER.info('No checklist directory') - diff --git a/resource_sharing/resource_handler/symbol_handler.py b/resource_sharing/resource_handler/symbol_handler.py index ea38d914..c6d654eb 100644 --- a/resource_sharing/resource_handler/symbol_handler.py +++ b/resource_sharing/resource_handler/symbol_handler.py @@ -57,8 +57,7 @@ def _get_child_group_tag(self, group_or_tag_id, file_name): (QGIS3, no hierarchy) for the styles. Returns the id of the group or tag id. Use a slash and the file_name as a way of simulating a tree - in QGIS3. - """ + in QGIS3.""" try: # QGIS 2 group = self.style.groupId(file_name) @@ -68,8 +67,9 @@ def _get_child_group_tag(self, group_or_tag_id, file_name): except AttributeError: # not QGIS 2, so hopefully QGIS 3 # tag_name = self.style.tag(group_or_tag_id) + '/' + file_name - tag_name = ('%s (%s)/') % (self.collection['name'], - self.collection['repository_name']) + file_name + tag_name = (('%s (%s)/') % + (self.collection['name'], + self.collection['repository_name'])) + file_name tag = self.style.tagId(tag_name) if tag != 0: return tag diff --git a/resource_sharing/utilities.py b/resource_sharing/utilities.py index 6ac0d234..6b4b0230 100644 --- a/resource_sharing/utilities.py +++ b/resource_sharing/utilities.py @@ -25,6 +25,7 @@ 'checklists': 'Dataset QA Workbench checklist', } + def resources_path(*args): """Get the absolute path to resources in the resources dir. @@ -40,6 +41,7 @@ def resources_path(*args): path = (path / item) return path + def ui_path(*args): """Get the absolute path to the ui file from the UI dir. @@ -55,31 +57,38 @@ def ui_path(*args): path = (path / item) return path + def user_expressions_group(): """Get the user expressions group.""" return '/expressions/user' + def repo_settings_group(): """Get the settings group for Resource Sharing Dialog.""" return '/ResourceSharing/repository' + def resource_sharing_group(): """Get the settings group for the local collection directories.""" return '/ResourceSharing' + def repositories_cache_path(): """Get the path to the repositories cache.""" return Path(QgsApplication.qgisSettingsDirPath(), 'resource_sharing', 'repositories_cache') + def local_collection_root_dir_key(): """The QSettings key for the local collections root dir.""" return 'localCollectionDir' + def default_local_collection_root_dir(): return Path(QgsApplication.qgisSettingsDirPath(), 'resource_sharing', 'collections') + def local_collection_path(id=None): """Get the path to the local collection dir. @@ -128,6 +137,7 @@ def local_collection_path(id=None): pass return path + def old_local_collection_path(id=None): """Get the path to the old local collection dir. (in case we would like to help the users migrate) @@ -157,6 +167,7 @@ def qgis_version(): version = int(version) return version + def render_template(filename, context): """Render a template with the specified filename. :param filename: The filename (must be in the template directory) @@ -170,4 +181,3 @@ def render_template(filename, context): return jinja2.Environment( loader=jinja2.FileSystemLoader(str(path)) ).get_template(filename).render(context) -