Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PEP8 issues #157

Merged
merged 1 commit into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions resource_sharing/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion resource_sharing/resource_handler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion resource_sharing/resource_handler/checklist_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ def uninstall(self):
self.checklists_directory.rmdir()
else:
LOGGER.info('No checklist directory')

8 changes: 4 additions & 4 deletions resource_sharing/resource_handler/symbol_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
12 changes: 11 additions & 1 deletion resource_sharing/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'checklists': 'Dataset QA Workbench checklist',
}


def resources_path(*args):
"""Get the absolute path to resources in the resources dir.

Expand All @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -170,4 +181,3 @@ def render_template(filename, context):
return jinja2.Environment(
loader=jinja2.FileSystemLoader(str(path))
).get_template(filename).render(context)