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

Enable reloading the directory (and some PEP8 / formatting updates) #153

Merged
merged 8 commits into from
Aug 28, 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
2 changes: 2 additions & 0 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ deprecated=False
icon=resources/icon.png
changelog=
0.15.2 - GUI improvements (#138, #139, #140, #141)
- Add button for reloading the QGIS directory of approved resources (#145)
- Fix bug in the handling of QGIS directory updates (#146)
0.15.1 - Fix incorrect handling of searchPathsForSVG setting (#135)
- Handle XML parsing exceptions for QML files
0.15.0 - Support expressions (#130). Switch to Python pathlib.
Expand Down
85 changes: 42 additions & 43 deletions resource_sharing/collection_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# coding=utf-8
import hashlib
# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
Expand Down Expand Up @@ -95,57 +94,57 @@ def get_html(self, collection_id):
html = ''
resource_types = 0
if 'svg' in config.COLLECTIONS[collection_id].keys():
html = html + str(config.COLLECTIONS[collection_id]['svg']) + ' SVG'
if config.COLLECTIONS[collection_id]['svg'] > 1:
html = html + 's'
resource_types = resource_types + 1
html = html + str(config.COLLECTIONS[collection_id]['svg']) + ' SVG'
if config.COLLECTIONS[collection_id]['svg'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'style' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['style']) + ' Layer style (QML) file'
if config.COLLECTIONS[collection_id]['style'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['style']) + ' Layer style (QML) file'
if config.COLLECTIONS[collection_id]['style'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'symbol' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['symbol']) + ' Symbol (XML) file'
if config.COLLECTIONS[collection_id]['symbol'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['symbol']) + ' Symbol (XML) file'
if config.COLLECTIONS[collection_id]['symbol'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'models' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['models']) + ' Processing model'
if config.COLLECTIONS[collection_id]['models'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['models']) + ' Processing model'
if config.COLLECTIONS[collection_id]['models'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'expressions' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['expressions']) + ' Expression (JSON) file'
if config.COLLECTIONS[collection_id]['expressions'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['expressions']) + ' Expression (JSON) file'
if config.COLLECTIONS[collection_id]['expressions'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'processing' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['processing']) + ' Processing script'
if config.COLLECTIONS[collection_id]['processing'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['processing']) + ' Processing script'
if config.COLLECTIONS[collection_id]['processing'] > 1:
html = html + 's'
resource_types = resource_types + 1
if 'rscripts' in config.COLLECTIONS[collection_id].keys():
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['rscripts']) + ' R script'
if config.COLLECTIONS[collection_id]['rscripts'] > 1:
html = html + 's'
resource_types = resource_types + 1
if resource_types > 0:
html = html + ', '
html = html + str(config.COLLECTIONS[collection_id]['rscripts']) + ' R script'
if config.COLLECTIONS[collection_id]['rscripts'] > 1:
html = html + 's'
resource_types = resource_types + 1
html = html + '.<br><i>Reinstall</i> to update'
if resource_types == 0:
html = '<i>No standard resources found</i>.'
html = '<i>No standard resources found</i>.'
if config.COLLECTIONS[collection_id]['status'] != COLLECTION_INSTALLED_STATUS:
html = '<i>Unknown before installation</i>'
html = '<i>Unknown before installation</i>'

config.COLLECTIONS[collection_id]['resources_html'] = html
context = {
Expand Down
Loading