diff --git a/metadata.txt b/metadata.txt
index 7e8bca4e..358bf1fd 100644
--- a/metadata.txt
+++ b/metadata.txt
@@ -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.
diff --git a/resource_sharing/collection_manager.py b/resource_sharing/collection_manager.py
index 76ef3215..07b6bde1 100644
--- a/resource_sharing/collection_manager.py
+++ b/resource_sharing/collection_manager.py
@@ -1,6 +1,5 @@
# coding=utf-8
import hashlib
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -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 + '.
Reinstall to update'
if resource_types == 0:
- html = 'No standard resources found.'
+ html = 'No standard resources found.'
if config.COLLECTIONS[collection_id]['status'] != COLLECTION_INSTALLED_STATUS:
- html = 'Unknown before installation'
+ html = 'Unknown before installation'
config.COLLECTIONS[collection_id]['resources_html'] = html
context = {
diff --git a/resource_sharing/gui/resource_sharing_dialog.py b/resource_sharing/gui/resource_sharing_dialog.py
index 84e4f52c..f505702e 100644
--- a/resource_sharing/gui/resource_sharing_dialog.py
+++ b/resource_sharing/gui/resource_sharing_dialog.py
@@ -51,11 +51,9 @@
QProgressDialog,
QDialogButtonBox)
-
from qgis.gui import QgsMessageBar
from qgis.core import Qgis
from qgis.core import QgsSettings
-
from resource_sharing.gui.manage_dialog import ManageRepositoryDialog
from resource_sharing.repository_manager import RepositoryManager
from resource_sharing.collection_manager import (
@@ -79,12 +77,12 @@
COLLECTION_ALL_STATUS,
COLLECTION_INSTALLED_STATUS)
from resource_sharing import config
-
FORM_CLASS, _ = uic.loadUiType(str(ui_path('resource_sharing_dialog_base.ui')))
LOGGER = logging.getLogger('QGIS Resource Sharing')
REPOSITORY_ITEM = 1000
COLLECTION_ITEM = 2000
+
class ResourceSharingDialog(QDialog, FORM_CLASS):
TAB_ALL = 0
TAB_INSTALLED = 1
@@ -102,7 +100,6 @@ def __init__(self, parent=None, iface=None):
super(ResourceSharingDialog, self).__init__(parent)
self.setupUi(self)
self.iface = iface
-
# Reconfigure UI
self.setModal(True)
self.button_edit.setEnabled(False)
@@ -110,7 +107,6 @@ def __init__(self, parent=None, iface=None):
self.button_install.setEnabled(False)
self.button_open.setEnabled(False)
self.button_uninstall.setEnabled(False)
-
# Set up the "main menu" - QListWidgetItem
# All collections
icon_all = QIcon()
@@ -144,20 +140,16 @@ def __init__(self, parent=None, iface=None):
item_settings.setIcon(icon_settings)
item_settings.setText(self.tr('Settings'))
item_all.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
-
# Add the items to the list widget
self.menu_list_widget.addItem(item_all)
self.menu_list_widget.addItem(item_installed)
self.menu_list_widget.addItem(item_settings)
-
# Init the message bar
self.message_bar = QgsMessageBar(self)
self.message_bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
self.vlayoutRightColumn.insertWidget(0, self.message_bar)
-
# Progress dialog for long running processes
self.progress_dialog = None
-
# Init the repository manager dialog
self.repository_manager = RepositoryManager()
self.collection_manager = CollectionManager()
@@ -168,13 +160,13 @@ def __init__(self, parent=None, iface=None):
self.collection_proxy.setSourceModel(self.collections_model)
self.list_view_collections.setModel(self.collection_proxy)
# Active selected collection
- self._selected_collection_id = None
-
+ self._sel_coll_id = None
# Slots
self.button_add.clicked.connect(self.add_repository)
self.button_edit.clicked.connect(self.edit_repository)
self.button_delete.clicked.connect(self.delete_repository)
self.button_reload.clicked.connect(self.reload_repositories)
+ self.button_reload_dir.clicked.connect(self.reload_off_res_directory)
self.menu_list_widget.currentRowChanged.connect(self.set_current_tab)
self.list_view_collections.selectionModel().currentChanged.connect(
self.on_list_view_collections_clicked)
@@ -184,7 +176,6 @@ def __init__(self, parent=None, iface=None):
self.button_uninstall.clicked.connect(self.uninstall_collection)
self.button_box.button(QDialogButtonBox.Help).clicked.connect(
self.open_help)
-
# Populate the repositories widget and collections list view
self.populate_repositories_widget()
self.reload_collections_model()
@@ -235,7 +226,6 @@ def add_repository(self):
dlg = ManageRepositoryDialog(self)
if not dlg.exec_():
return
-
for repoName, repo in self.repository_manager.directories.items():
if dlg.line_edit_url.text().strip() == repo['url']:
self.message_bar.pushMessage(
@@ -249,16 +239,13 @@ def add_repository(self):
'Repositories must have unique names!'),
Qgis.Warning, 5)
return
-
repo_name = dlg.line_edit_name.text()
repo_url = dlg.line_edit_url.text().strip()
repo_auth_cfg = dlg.line_edit_auth_id.text().strip()
if repo_name in self.repository_manager.directories:
repo_name += '(2)'
-
# Show progress dialog
self.show_progress_dialog("Fetching repository's metadata")
-
# Add repository
try:
status, adderror = self.repository_manager.add_directory(
@@ -279,10 +266,8 @@ def add_repository(self):
Qgis.Warning, 5)
finally:
self.progress_dialog.hide()
-
# Reload data and widget
self.reload_data_and_widget()
-
# Deactivate edit and delete button
self.button_edit.setEnabled(False)
self.button_delete.setEnabled(False)
@@ -292,10 +277,8 @@ def edit_repository(self):
selected_item = self.tree_repositories.currentItem()
if selected_item:
repo_name = selected_item.text(0)
-
if not repo_name:
return
-
# Check if it is among the officially approved QGIS repositories
settings = QgsSettings()
settings.beginGroup(repo_settings_group())
@@ -306,17 +289,14 @@ def edit_repository(self):
'You can not edit the official repositories!'),
Qgis.Warning, 5)
return
-
dlg = ManageRepositoryDialog(self)
dlg.line_edit_name.setText(repo_name)
dlg.line_edit_url.setText(
self.repository_manager.directories[repo_name]['url'])
dlg.line_edit_auth_id.setText(
self.repository_manager.directories[repo_name]['auth_cfg'])
-
if not dlg.exec_():
return
-
# Check if the changed URL is already present and that
# the new repository name is unique
new_url = dlg.line_edit_url.text().strip()
@@ -335,17 +315,13 @@ def edit_repository(self):
'Repositories must have unique names!'),
Qgis.Warning, 5)
return
-
# Redundant
if (new_name in self.repository_manager.directories) and (
new_name != repo_name):
new_name += '(2)'
-
new_auth_cfg = dlg.line_edit_auth_id.text()
-
# Show progress dialog
self.show_progress_dialog("Fetching repository's metadata")
-
# Edit repository
try:
status, editerror = self.repository_manager.edit_directory(
@@ -368,10 +344,8 @@ def edit_repository(self):
self.tr('%s') % e, Qgis.Warning, 5)
finally:
self.progress_dialog.hide()
-
# Reload data and widget
self.reload_data_and_widget()
-
# Deactivate the edit and delete buttons
self.button_edit.setEnabled(False)
self.button_delete.setEnabled(False)
@@ -381,7 +355,6 @@ def delete_repository(self):
selected_item = self.tree_repositories.currentItem()
if selected_item:
repo_name = selected_item.text(0)
-
if not repo_name:
return
# Check if it is among the offical repositories
@@ -392,7 +365,6 @@ def delete_repository(self):
'You can not remove official repositories!'),
Qgis.Warning, 5)
return
-
warning = self.tr('Are you sure you want to remove the following '
'repository?') + '\n' + repo_name
if QMessageBox.warning(
@@ -418,11 +390,29 @@ def delete_repository(self):
self.button_edit.setEnabled(False)
self.button_delete.setEnabled(False)
+ def reload_off_res_directory(self):
+ """Slot called when the user clicks the 'Reload directory'
+ button."""
+ # Show progress dialog
+ self.show_progress_dialog('Reloading the official QGIS resource'
+ ' directory')
+ self.repository_manager._online_directories = {}
+ # Registered directories
+ self.repository_manager._directories = {}
+ self.repository_manager.fetch_online_directories()
+ # Load directory of repositories from settings
+ self.repository_manager.load_directories()
+ self.message_bar.pushMessage('On-line directory reloaded',
+ Qgis.Info, 5)
+ self.progress_dialog.hide()
+ # Reload data and widget
+ self.reload_data_and_widget()
+
def reload_repositories(self):
- """Slot for when user clicks reload repositories button."""
+ """Slot called when the user clicks the 'Reload repositories'
+ button."""
# Show progress dialog
self.show_progress_dialog('Reloading all repositories')
-
for repo_name in self.repository_manager.directories:
directory = self.repository_manager.directories[repo_name]
url = directory['url']
@@ -445,21 +435,19 @@ def reload_repositories(self):
self.message_bar.pushMessage(
self.tr('%s') % e,
Qgis.Warning, 5)
-
self.progress_dialog.hide()
# Reload data and widget
self.reload_data_and_widget()
def install_collection(self):
- """Slot for when the user clicks the install/reinstall button."""
+ """Slot called when the user clicks the Install/Reinstall button."""
# Save the current index to enable selection after installation
self.current_index = self.list_view_collections.currentIndex()
self.show_progress_dialog('Starting installation...')
self.progress_dialog.canceled.connect(self.install_canceled)
-
self.installer_thread = QThread()
self.installer_worker = CollectionInstaller(
- self.collection_manager, self._selected_collection_id)
+ self.collection_manager, self._sel_coll_id)
self.installer_worker.moveToThread(self.installer_thread)
self.installer_worker.finished.connect(self.install_finished)
self.installer_worker.aborted.connect(self.install_aborted)
@@ -478,45 +466,48 @@ def install_finished(self):
self.installer_thread.quit()
self.installer_thread.wait()
self.installer_thread.deleteLater()
-
if installStatus:
self.reload_collections_model()
# Report what has been installed
- message = '%s was successfully installed, containing:\n
' % (
- config.COLLECTIONS[self._selected_collection_id]['name'])
+ message = ('%s was successfully installed, '
+ 'containing:\n' %
+ (config.COLLECTIONS[self._sel_coll_id]['name']))
number = 0
- if 'style' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['style']
- message = message + '\n- ' + str(number) + ' Layer style (QML) file'
+ if 'style' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['style']
+ message = (message + '\n
- ' + str(number) +
+ ' Layer style (QML) file')
if number > 1:
message = message + 's'
- if 'symbol' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['symbol']
- message = message + '\n
- ' + str(number) + ' XML symbol file'
+ if 'symbol' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['symbol']
+ message = (message + '\n
- ' + str(number) +
+ ' XML symbol file')
if number > 1:
message = message + 's'
- if 'svg' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['svg']
+ if 'svg' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['svg']
message = message + '\n
- ' + str(number) + ' SVG file'
if number > 1:
message = message + 's'
- if 'models' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['models']
+ if 'models' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['models']
message = message + '\n
- ' + str(number) + ' model'
if number > 1:
message = message + 's'
- if 'expressions' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['expressions']
+ if 'expressions' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['expressions']
message = message + '\n
- ' + str(number) + ' expression file'
if number > 1:
message = message + 's'
- if 'processing' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['processing']
- message = message + '\n
- ' + str(number) + ' processing script'
+ if 'processing' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['processing']
+ message = (message + '\n
- ' + str(number) +
+ ' processing script')
if number > 1:
message = message + 's'
- if 'rscripts' in config.COLLECTIONS[self._selected_collection_id].keys():
- number = config.COLLECTIONS[self._selected_collection_id]['rscripts']
+ if 'rscripts' in config.COLLECTIONS[self._sel_coll_id].keys():
+ number = config.COLLECTIONS[self._sel_coll_id]['rscripts']
message = message + '\n
- ' + str(number) + ' R script'
if number > 1:
message = message + 's'
@@ -527,15 +518,15 @@ def install_finished(self):
oldRow = self.current_index.row()
newIndex = self.collections_model.createIndex(oldRow, 0)
selection_model = self.list_view_collections.selectionModel()
- selection_model.setCurrentIndex(newIndex, selection_model.ClearAndSelect)
+ selection_model.setCurrentIndex(newIndex,
+ selection_model.ClearAndSelect)
selection_model.select(newIndex, selection_model.ClearAndSelect)
# Update the buttons
self.button_install.setEnabled(True)
self.button_install.setText('Reinstall')
self.button_open.setEnabled(True)
self.button_uninstall.setEnabled(True)
-
- self.show_collection_metadata(self._selected_collection_id)
+ self.show_collection_metadata(self._sel_coll_id)
def install_canceled(self):
self.progress_dialog.hide()
@@ -551,10 +542,10 @@ def install_progress(self, text):
self.progress_dialog.setLabelText(text)
def uninstall_collection(self):
- """Slot called when user clicks the uninstall button."""
+ """Slot called when the user clicks the 'Uninstall' button."""
# get the QModelIndex for the item to be uninstalled
uninstall_index = self.list_view_collections.currentIndex()
- coll_id = self._selected_collection_id
+ coll_id = self._sel_coll_id
try:
self.collection_manager.uninstall(coll_id)
except Exception as e:
@@ -570,7 +561,6 @@ def uninstall_collection(self):
currentMenuRow = self.menu_list_widget.currentRow()
self.set_current_tab(currentMenuRow)
self.populate_repositories_widget()
-
rowCount = self.collection_proxy.rowCount()
if rowCount > 0:
# Set the current (and selected) row in the listview
@@ -578,16 +568,17 @@ def uninstall_collection(self):
# Check if this was the last element
rowCount = self.collection_proxy.rowCount()
if newRow == rowCount:
- newRow = newRow - 1
+ newRow = newRow - 1
# Select the new current element
newIndex = self.collections_model.createIndex(newRow, 0)
selection_model = self.list_view_collections.selectionModel()
- selection_model.setCurrentIndex(newIndex, selection_model.ClearAndSelect)
+ selection_model.setCurrentIndex(newIndex,
+ selection_model.ClearAndSelect)
# Get the id of the current collection
proxyModel = self.list_view_collections.model()
- proxyIndex = proxyModel.index(newRow,0)
+ proxyIndex = proxyModel.index(newRow, 0)
current_coll_id = proxyIndex.data(COLLECTION_ID_ROLE)
- self._selected_collection_id = current_coll_id
+ self._sel_coll_id = current_coll_id
# Update buttons
status = config.COLLECTIONS[current_coll_id]['status']
if status == COLLECTION_INSTALLED_STATUS:
@@ -609,8 +600,8 @@ def uninstall_collection(self):
self.button_uninstall.setEnabled(False)
def open_collection(self):
- """Slot for when user clicks 'Open' button."""
- collection_path = local_collection_path(self._selected_collection_id)
+ """Slot called when the user clicks the 'Open' button."""
+ collection_path = local_collection_path(self._sel_coll_id)
directory_url = QUrl.fromLocalFile(str(collection_path))
QDesktopServices.openUrl(directory_url)
@@ -631,6 +622,7 @@ def populate_repositories_widget(self):
installed_collections = \
self.collection_manager.get_installed_collections()
# Export the updated ones from the repository manager
+ repo_Font = QFont()
repo_with_installed_Font = QFont()
repo_with_installed_Font.setWeight(60)
collection_brush = QBrush(Qt.darkGray)
@@ -638,11 +630,20 @@ def populate_repositories_widget(self):
for repo_name in self.repository_manager.directories:
url = self.repository_manager.directories[repo_name]['url']
item = QTreeWidgetItem(self.tree_repositories, REPOSITORY_ITEM)
+ # Is the repository in the QGIS resource directory?
+ if url in self.repository_manager._online_directories.values():
+ repo_with_installed_Font.setUnderline(True)
+ repo_Font.setUnderline(True)
+ else:
+ repo_with_installed_Font.setUnderline(False)
+ repo_Font.setUnderline(False)
item.setText(0, repo_name)
item.setText(1, url)
+ item.setFont(0, repo_Font)
for coll_id in config.COLLECTIONS:
if ('repository_name' in config.COLLECTIONS[coll_id].keys() and
- config.COLLECTIONS[coll_id]['repository_name'] == repo_name):
+ config.COLLECTIONS[coll_id]['repository_name'] ==
+ repo_name):
coll_name = config.COLLECTIONS[coll_id]['name']
coll_tags = config.COLLECTIONS[coll_id]['tags']
collectionItem = QTreeWidgetItem(item, COLLECTION_ITEM)
@@ -650,10 +651,13 @@ def populate_repositories_widget(self):
collectionFont = QFont()
collectionFont.setStyle(QFont.StyleItalic)
collitemtext = coll_name
- if installed_collections and coll_id in installed_collections.keys():
- collitemtext = coll_name + ' (installed)'
- brush = installed_collection_brush
- item.setFont(0,repo_with_installed_Font)
+ if (installed_collections and
+ coll_id in installed_collections.keys()):
+ collitemtext = coll_name + ' (installed)'
+ brush = installed_collection_brush
+ item.setFont(0, repo_with_installed_Font)
+ item.setForeground(0, brush)
+ item.setForeground(1, brush)
collectionItem.setFont(0, collectionFont)
collectionItem.setForeground(0, brush)
collectionItem.setText(0, collitemtext)
@@ -677,8 +681,9 @@ def reload_collections_model(self):
collection_status = config.COLLECTIONS[id]['status']
repository_name = ''
if 'repository_name' in config.COLLECTIONS[id].keys():
- repository_name = config.COLLECTIONS[id]['repository_name']
- item = QStandardItem(collection_name + ' (' + repository_name + ')')
+ repository_name = config.COLLECTIONS[id]['repository_name']
+ item = QStandardItem(collection_name + ' (' +
+ repository_name + ')')
item.setEditable(False)
item.setData(id, COLLECTION_ID_ROLE)
item.setData(collection_name, COLLECTION_NAME_ROLE)
@@ -702,11 +707,12 @@ def on_tree_repositories_itemSelectionChanged(self):
repo_name = selected_item.text(0)
if not repo_name:
return
- if not repo_name in self.repository_manager.directories.keys():
+ if repo_name not in self.repository_manager.directories.keys():
return
repo_url = self.repository_manager.directories[repo_name]['url']
# Disable the edit and delete buttons for "official" repositories
- if repo_url in self.repository_manager._online_directories.values():
+ if (repo_url in
+ self.repository_manager._online_directories.values()):
self.button_edit.setEnabled(False)
self.button_delete.setEnabled(False)
else:
@@ -721,15 +727,15 @@ def on_tree_repositories_itemSelectionChanged(self):
self.button_delete.setEnabled(False)
def on_list_view_collections_clicked(self, index):
- """Slot for when the list_view_collections is clicked."""
+ """Slot called when the user clicks an item in
+ list_view_collections."""
real_index = self.collection_proxy.mapToSource(index)
if real_index.row() != -1:
collection_item = self.collections_model.itemFromIndex(real_index)
collection_id = collection_item.data(COLLECTION_ID_ROLE)
- self._selected_collection_id = collection_id
-
+ self._sel_coll_id = collection_id
# Enable / disable buttons
- status = config.COLLECTIONS[self._selected_collection_id]['status']
+ status = config.COLLECTIONS[self._sel_coll_id]['status']
is_installed = status == COLLECTION_INSTALLED_STATUS
if is_installed:
self.button_install.setEnabled(True)
@@ -741,7 +747,6 @@ def on_list_view_collections_clicked(self, index):
self.button_install.setText('Install')
self.button_open.setEnabled(False)
self.button_uninstall.setEnabled(False)
-
# Show metadata
self.show_collection_metadata(collection_id)
@@ -759,7 +764,7 @@ def show_collection_metadata(self, id):
self.web_view_details.setHtml(html)
def reject(self):
- """Slot when the dialog is closed."""
+ """Slot called when the dialog is closed."""
# Serialize collections to settings
self.repository_manager.serialize_repositories()
self.done(0)
@@ -787,5 +792,4 @@ def show_progress_dialog(self, text):
self.progress_dialog.setMinimum(0)
self.progress_dialog.setValue(0)
self.progress_dialog.setLabelText(text)
-
self.progress_dialog.show()
diff --git a/resource_sharing/gui/ui/resource_sharing_dialog_base.ui b/resource_sharing/gui/ui/resource_sharing_dialog_base.ui
index 734da99b..d240f820 100644
--- a/resource_sharing/gui/ui/resource_sharing_dialog_base.ui
+++ b/resource_sharing/gui/ui/resource_sharing_dialog_base.ui
@@ -69,7 +69,16 @@
QLayout::SetDefaultConstraint
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
@@ -143,7 +152,16 @@
5
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
@@ -338,11 +356,20 @@
QFrame::Sunken
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
-
+
0
@@ -355,7 +382,7 @@
0
-
+
about:blank
@@ -438,7 +465,16 @@
QFrame::Raised
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
@@ -460,8 +496,8 @@
0
0
- 596
- 534
+ 689
+ 537
@@ -508,7 +544,17 @@
- Reload Repositories
+ Reload repositories
+
+
+
+ -
+
+
+ Reload the official QGIS online directory of repositories
+
+
+ Reload directory
diff --git a/resource_sharing/plugin.py b/resource_sharing/plugin.py
index d2dbc0c1..a6bf83fc 100644
--- a/resource_sharing/plugin.py
+++ b/resource_sharing/plugin.py
@@ -19,16 +19,13 @@
* *
***************************************************************************/
"""
-# Use pathlib instead of os.path
from pathlib import Path
-
from qgis.PyQt.QtCore import QSettings, QTranslator, qVersion, QCoreApplication
from qgis.PyQt.QtGui import QIcon
try:
from qgis.PyQt.QtGui import QAction # QT 4 - could be removed
except ImportError:
from qgis.PyQt.QtWidgets import QAction # QT 5
-
from .gui.resource_sharing_dialog import ResourceSharingDialog
from .utilities import resources_path
diff --git a/resource_sharing/repository_handler/filesystem_handler.py b/resource_sharing/repository_handler/filesystem_handler.py
index ae8812d1..54adbeb4 100644
--- a/resource_sharing/repository_handler/filesystem_handler.py
+++ b/resource_sharing/repository_handler/filesystem_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
diff --git a/resource_sharing/repository_handler/remote_git_handler.py b/resource_sharing/repository_handler/remote_git_handler.py
index acaf1236..edd25d38 100644
--- a/resource_sharing/repository_handler/remote_git_handler.py
+++ b/resource_sharing/repository_handler/remote_git_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -108,7 +107,7 @@ def download_collection(self, id, register_name):
if local_repo_dir.exists():
try:
shutil.rmtree(str(local_repo_dir))
- except:
+ except Exception:
pass
if not (local_repo_dir / '.git').exists():
local_repo_dir.mkdir(parents=True)
diff --git a/resource_sharing/repository_manager.py b/resource_sharing/repository_manager.py
index d1a5541a..26d26966 100644
--- a/resource_sharing/repository_manager.py
+++ b/resource_sharing/repository_manager.py
@@ -1,14 +1,10 @@
# coding=utf-8
import logging
-
import csv
-# Use pathlib instead of os.path
from pathlib import Path
import pickle
-
from qgis.PyQt.QtCore import QObject, QSettings, QTemporaryFile
from qgis.core import QgsSettings
-
from resource_sharing.utilities import (
repo_settings_group, local_collection_path, repositories_cache_path)
from resource_sharing.repository_handler import BaseRepositoryHandler
@@ -70,12 +66,12 @@ def __init__(self):
self._repositories = {}
# Collection manager instance to deal with collections
self._collections_manager = CollectionManager()
+ # Load repositories from cache
+ self.load_repositories()
# Fetch online directories
self.fetch_online_directories()
# Load directory of repositories from settings
self.load_directories()
- # Load repositories from cache
- self.load_repositories()
@property
def directories(self):
@@ -96,7 +92,6 @@ def fetch_online_directories(self):
if directory_file.open():
directory_file.write(downloader.content)
directory_file.close()
-
with open(directory_file.fileName()) as csv_file:
reader = csv.DictReader(csv_file, fieldnames=('name', 'url'))
for row in reader:
@@ -115,13 +110,13 @@ def fetch_online_directories(self):
LOGGER.warning("Missing URL for repository" +
str(row['name']) +
" - not added")
- # Save it to cache
+ # Save to settings
settings = QgsSettings()
settings.beginGroup(repo_settings_group())
settings.setValue('online_directories', self._online_directories)
settings.endGroup()
else:
- # Just use cache from previous use
+ # Use settings
settings = QgsSettings()
settings.beginGroup(repo_settings_group())
self._online_directories = settings.value('online_directories', {})
@@ -132,7 +127,6 @@ def load_directories(self):
self._directories = {}
settings = QgsSettings()
settings.beginGroup(repo_settings_group())
-
# Loop through the repositories from the official directory
for online_dir_name in self._online_directories:
# Check if the repository is already present
@@ -151,7 +145,6 @@ def load_directories(self):
if not repo_present:
self.add_directory(
online_dir_name, self._online_directories[online_dir_name])
-
for repo_name in settings.childGroups():
self._directories[repo_name] = {}
url = settings.value(
@@ -177,7 +170,6 @@ def add_directory(self, repo_name, url, auth_cfg=None):
str(url) + "'!")
if auth_cfg:
repo_handler.auth_cfg = auth_cfg
-
# Fetch metadata
status, fetcherror = repo_handler.fetch_metadata()
if status:
@@ -189,7 +181,6 @@ def add_directory(self, repo_name, url, auth_cfg=None):
str(repo_name) + ":\n" + str(me))
LOGGER.warning(metadata_warning)
return False, metadata_warning
-
# Add the repository and its collections
self._repositories[repo_name] = collections
self.rebuild_collections()
@@ -202,7 +193,6 @@ def add_directory(self, repo_name, url, auth_cfg=None):
settings.endGroup()
# Serialize repositories every time we successfully added a repo
self.serialize_repositories()
-
return status, fetcherror
def edit_directory(
@@ -251,7 +241,6 @@ def edit_directory(
else:
# old_repo_name == new_repo_name and old_url == new_url
# or new_url != old_url
-
# Fetch the metadata (metadata.ini) from the new url
repo_handler = BaseRepositoryHandler.get_handler(new_url)
if repo_handler is None:
@@ -261,7 +250,6 @@ def edit_directory(
if new_auth_cfg:
repo_handler.auth_cfg = new_auth_cfg
status, fetcherror = repo_handler.fetch_metadata()
-
if status:
# Parse metadata
try:
@@ -277,7 +265,6 @@ def edit_directory(
for old_collection in old_collections:
if old_collection['status'] == COLLECTION_INSTALLED_STATUS:
installed_old_collections.append(old_collection)
-
# Handling installed collections
# An old collection that is present in the new location
# (URL) is identified by its register name.
@@ -294,7 +281,6 @@ def edit_directory(
for installed_collection in installed_old_collections:
reg_name = installed_collection['register_name']
is_present = False
-
for collection in new_collections:
# Look for collections that are already present
if collection['register_name'] == reg_name:
@@ -305,21 +291,20 @@ def edit_directory(
collection['status'] = COLLECTION_INSTALLED_STATUS
# Keep the collection statistics
for key in installed_collection.keys():
- if key in ['models', 'processing', 'rscripts', 'style', 'svg', 'symbol', 'expressions']:
+ if key in ['models', 'processing',
+ 'rscripts', 'style', 'svg',
+ 'symbol', 'expressions']:
collection[key] = installed_collection[key]
-
else:
# Different repository URLs, so append
new_collections.append(installed_collection)
break
if not is_present:
new_collections.append(installed_collection)
-
# Remove the old repository and add the new one
self._repositories.pop(old_repo_name, None)
self._repositories[new_repo_name] = new_collections
self.rebuild_collections()
-
# Update QgsSettings
settings = QgsSettings()
settings.beginGroup(repo_settings_group())
@@ -378,7 +363,6 @@ def rebuild_collections(self):
)
collection['repository_name'] = repo
config.COLLECTIONS[collection_id] = collection
-
# Get the collection path (updating if neccessary)
collection_path = local_collection_path(collection_id)
# Check the file system to see if the collection exists.
@@ -408,7 +392,6 @@ def serialize_repositories(self):
"""Save repositories to cache."""
if not repositories_cache_path().parent.exists():
repositories_cache_path().parent.mkdir(parents=True)
-
self.resync_repository()
with open(str(repositories_cache_path()), 'wb') as f:
pickle.dump(self._repositories, f)
diff --git a/resource_sharing/resource_handler/base.py b/resource_sharing/resource_handler/base.py
index f0b8e2a2..26c6e63c 100644
--- a/resource_sharing/resource_handler/base.py
+++ b/resource_sharing/resource_handler/base.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
from six import add_metaclass
diff --git a/resource_sharing/resource_handler/expression_handler.py b/resource_sharing/resource_handler/expression_handler.py
index faa53cf5..69ade2cd 100644
--- a/resource_sharing/resource_handler/expression_handler.py
+++ b/resource_sharing/resource_handler/expression_handler.py
@@ -10,15 +10,16 @@
from qgis.core import QGis as Qgis
from resource_sharing.resource_handler.base import BaseResourceHandler
-from resource_sharing.utilities import (user_expressions_group, repo_settings_group, qgis_version)
+from resource_sharing.utilities import (user_expressions_group,
+ repo_settings_group, qgis_version)
hasExprBuilder = False
-#try:
-# from qgis.core import QgsExpressions
+# try:
+# from qgis.core import QgsExpressions
try:
from qgis.gui import QgsExpressionBuilderWidget
-except:
+except ImportError:
hasExprBuilder = False
else:
hasExprBuilder = True
@@ -26,6 +27,7 @@
LOGGER = logging.getLogger('QGIS Resource Sharing')
EXPRESSIONS = 'expressions'
+
class ExpressionHandler(BaseResourceHandler):
"""Concrete class of the Expression handler."""
IS_DISABLED = False
@@ -47,7 +49,7 @@ def install(self):
return
# Uninstall first (in case it is a reinstall)
- #self.uninstall()
+ # self.uninstall()
# Get all the expressions in the collection
json_files = []
@@ -66,16 +68,17 @@ def install(self):
with open(json_file, 'rb') as expr_file:
expr_json = expr_file.read()
jsontext = json.loads(expr_json)
- #QgsExpressionBuilderWidget loadExpressionsFromJson
+ # QgsExpressionBuilderWidget loadExpressionsFromJson
expressions = jsontext['expressions']
for expr in expressions:
expr_name = namePrefix + expr['name']
- expr_value =expr['expression']
+ expr_value = expr['expression']
expr_help = expr['description']
settings.setValue(expr_name + '/expression', expr_value)
settings.setValue(expr_name + '/helpText', expr_help)
- aftervalue = settings.value(expr_name + '/expression', '', type=unicode).strip()
+ aftervalue = settings.value(expr_name + '/expression', '',
+ type=unicode).strip()
valid += 1
settings.endGroup()
if valid >= 0:
@@ -108,7 +111,6 @@ def uninstall(self):
for expr in expressions:
expr_name = namePrefix + expr['name']
if settings.contains(expr_name + '/expression'):
- settings.remove(expr_name)
+ settings.remove(expr_name)
settings.endGroup()
# Remove files - nothing to remove
-
diff --git a/resource_sharing/resource_handler/model_handler.py b/resource_sharing/resource_handler/model_handler.py
index e3a88bb4..074f3568 100644
--- a/resource_sharing/resource_handler/model_handler.py
+++ b/resource_sharing/resource_handler/model_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -86,4 +85,3 @@ def Models_folder(self):
"""Return the folder where processing expects to find models."""
# Use the default location
return self.default_models_folder()
-
diff --git a/resource_sharing/resource_handler/processing_handler.py b/resource_sharing/resource_handler/processing_handler.py
index c6dcd593..4bbc1196 100644
--- a/resource_sharing/resource_handler/processing_handler.py
+++ b/resource_sharing/resource_handler/processing_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -46,7 +45,7 @@ def install(self):
valid += 1
except OSError as e:
LOGGER.error("Could not copy script '" +
- str(processing_file) + "'\n" + str(e))
+ str(processing_file) + "'\n" + str(e))
if valid > 0:
self.refresh_script_provider()
self.collection[PROCESSING] = valid
@@ -71,8 +70,7 @@ def refresh_script_provider(self):
except Error as e:
LOGGER.error("Exception refreshing algorithms:\n" +
str(e))
-
+
def scripts_folder(self):
"""Return the default processing scripts folder."""
return ScriptUtils.defaultScriptsFolder()
-
diff --git a/resource_sharing/resource_handler/r_handler.py b/resource_sharing/resource_handler/r_handler.py
index bd4384c2..0fe92b9c 100644
--- a/resource_sharing/resource_handler/r_handler.py
+++ b/resource_sharing/resource_handler/r_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -79,7 +78,8 @@ def refresh_Rscript_provider(self):
try:
r_provider.refreshAlgorithms()
except Error as e:
- LOGGER.error("Exception when refreshing after adding R scripts:\n" +
+ LOGGER.error("Exception when refreshing after adding"
+ " R scripts:\n" +
str(e))
def default_rscripts_folder(self):
@@ -93,4 +93,3 @@ def default_rscripts_folder(self):
def RScripts_folder(self):
"""Return the default R scripts folder."""
return self.default_rscripts_folder()
-
diff --git a/resource_sharing/resource_handler/style_handler.py b/resource_sharing/resource_handler/style_handler.py
index 20d2f978..860c8eaf 100644
--- a/resource_sharing/resource_handler/style_handler.py
+++ b/resource_sharing/resource_handler/style_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import logging
@@ -10,6 +9,7 @@
LOGGER = logging.getLogger('QGIS Resource Sharing')
STYLE = 'style'
+
class StyleResourceHandler(BaseResourceHandler, SymbolResolverMixin):
"""Style handler class."""
IS_DISABLED = False
@@ -54,4 +54,3 @@ def uninstall(self):
"""Uninstall the style."""
# Styles are not installed, so do nothing.
pass
-
diff --git a/resource_sharing/resource_handler/svg_handler.py b/resource_sharing/resource_handler/svg_handler.py
index 53e3856a..596e0cd3 100644
--- a/resource_sharing/resource_handler/svg_handler.py
+++ b/resource_sharing/resource_handler/svg_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import shutil
import logging
@@ -16,6 +15,7 @@
SVG = 'svg'
LOGGER = logging.getLogger('QGIS Resource Sharing')
+
class SVGResourceHandler(BaseResourceHandler):
"""The SVG resource handler class."""
IS_DISABLED = False
@@ -39,7 +39,7 @@ def svg_search_paths(cls):
search_paths = search_paths_settings.split('|')
else:
# QGIS 3
- # Check if it is a string (single directory)
+ # Check if it is a string (single directory)
if isinstance(search_paths_settings, str):
search_paths = [search_paths_settings]
else:
@@ -77,7 +77,6 @@ def install(self):
return
# Add to the SVG search paths
search_paths = self.svg_search_paths()
- #if local_collection_path() not in search_paths:
if str(local_collection_path()) not in search_paths:
search_paths.append(str(local_collection_path()))
self.set_svg_search_paths(search_paths)
@@ -109,4 +108,3 @@ def uninstall(self):
if str(local_collection_path()) in search_paths:
search_paths.remove(str(local_collection_path()))
self.set_svg_search_paths(search_paths)
-
diff --git a/resource_sharing/resource_handler/symbol_handler.py b/resource_sharing/resource_handler/symbol_handler.py
index 01b13cc1..ea38d914 100644
--- a/resource_sharing/resource_handler/symbol_handler.py
+++ b/resource_sharing/resource_handler/symbol_handler.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import logging
@@ -17,6 +16,7 @@
LOGGER = logging.getLogger('QGIS Resource Sharing')
SYMBOL = 'symbol'
+
class SymbolResourceHandler(BaseResourceHandler, SymbolResolverMixin):
"""Concrete class of the Symbol handler."""
IS_DISABLED = False
@@ -44,12 +44,12 @@ def _get_parent_group_or_tag(self):
return group
return self.style.addGroup(parent_group_name)
except AttributeError:
- # not QGIS 2, so hopefully QGIS 3
- #tag = self.style.tagId(parent_group_name)
- #if tag != 0:
- # return tag
- #return self.style.addTag(parent_group_name)
- # We don't want to create an empty "parent" tag
+ # # not QGIS 2, so hopefully QGIS 3
+ # tag = self.style.tagId(parent_group_name)
+ # if tag != 0:
+ # return tag
+ # return self.style.addTag(parent_group_name)
+ # # We don't want to create an empty "parent" tag
return None
def _get_child_group_tag(self, group_or_tag_id, file_name):
@@ -67,15 +67,17 @@ def _get_child_group_tag(self, group_or_tag_id, file_name):
return self.style.addGroup(file_name, group_or_tag_id)
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 = self.style.tag(group_or_tag_id) + '/' + 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
return self.style.addTag(tag_name)
def _get_child_groups_tags_ids(self):
- """Retrieve ids for the child groups (for QGIS2) or tags (for QGIS3)."""
+ """Retrieve ids for the child groups (for QGIS2) or tags
+ (for QGIS3)."""
parent_group_name = '%s (%s)' % (
self.collection['name'], self.collection['repository_name'])
try:
@@ -150,13 +152,15 @@ def install(self):
for symbol_file in symbol_files:
file_name = symbol_file.stem
# Groups in QGIS2, tags in QGIS3...
- groupOrTag_id = self._get_child_group_tag(group_or_tag_id, file_name)
+ groupOrTag_id = self._get_child_group_tag(group_or_tag_id,
+ file_name)
# Modify the symbol file to fix image and SVG paths
self.resolve_dependency(str(symbol_file))
# Add all symbols and colorramps and group / tag them
symbol_xml_extractor = SymbolXMLExtractor(str(symbol_file))
for symbol in symbol_xml_extractor.symbols:
- symbol_name = '%s (%s)' % (symbol['name'], self.collection['repository_name'])
+ symbol_name = '%s (%s)' % (symbol['name'],
+ self.collection['repository_name'])
# self.resolve_dependency(symbol[SYMBOL])
if self.style.addSymbol(symbol_name, symbol[SYMBOL], True):
self._group_or_tag(QgsStyle.SymbolEntity, symbol_name,
@@ -181,8 +185,9 @@ def install(self):
for labelsetting in symbol_xml_extractor.labelsettings:
labelsetting_name = '%s (%s)' % (
labelsetting['name'], self.collection['repository_name'])
- if self.style.addLabelSettings(
- labelsetting_name, labelsetting['labelsettings'], True):
+ if self.style.addLabelSettings(labelsetting_name,
+ labelsetting['labelsettings'],
+ True):
self._group_or_tag(QgsStyle.LabelSettingsEntity,
labelsetting_name, groupOrTag_id)
if valid >= 0:
@@ -210,12 +215,14 @@ def uninstall(self):
# Remove this tag / child group
self._group_or_tag_remove(child_group_id)
continue
- # Get all the textformats for this tag / child group and remove them
+ # Get all the textformats for this tag / child group
+ # and remove them
textformats = self._get_symbols_for_group_or_tag(
QgsStyle.TextFormatEntity, child_group_id)
for textformat in textformats:
self.style.removeTextFormat(textformat)
- # Get all the labelsettings for this tag / child group and remove them
+ # Get all the labelsettings for this tag / child group
+ # and remove them
labelsettings = self._get_symbols_for_group_or_tag(
QgsStyle.LabelSettingsEntity, child_group_id)
for labelsetting in labelsettings:
@@ -224,4 +231,3 @@ def uninstall(self):
self._group_or_tag_remove(child_group_id)
# Remove the group / tag:
self._group_or_tag_remove(group_or_tag_id)
-
diff --git a/resource_sharing/resource_handler/symbol_resolver_mixin.py b/resource_sharing/resource_handler/symbol_resolver_mixin.py
index cfe9d250..21347331 100644
--- a/resource_sharing/resource_handler/symbol_resolver_mixin.py
+++ b/resource_sharing/resource_handler/symbol_resolver_mixin.py
@@ -1,5 +1,4 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import xml.etree.ElementTree as ET
diff --git a/resource_sharing/symbol_xml_extractor.py b/resource_sharing/symbol_xml_extractor.py
index 761ee99c..e6c1f091 100644
--- a/resource_sharing/symbol_xml_extractor.py
+++ b/resource_sharing/symbol_xml_extractor.py
@@ -9,6 +9,7 @@
LOGGER = logging.getLogger('QGIS Resource Sharing')
+
class SymbolXMLExtractor(object):
"""Parses the given file and returns the symbols and colorramps"""
def __init__(self, xml_path):
diff --git a/resource_sharing/utilities.py b/resource_sharing/utilities.py
index 0140c4b9..99180d9e 100644
--- a/resource_sharing/utilities.py
+++ b/resource_sharing/utilities.py
@@ -1,18 +1,14 @@
# coding=utf-8
-# Use pathlib instead of os.path
from pathlib import Path
import logging
-
import ntpath
from ext_libs.pathvalidate import sanitize_filename
-
from qgis.PyQt.QtCore import QDir, QSettings
from qgis.core import QgsSettings
try:
from qgis.core import QgsApplication, QGis as Qgis
except ImportError:
from qgis.core import QgsApplication, Qgis
-
from resource_sharing import config
import jinja2
@@ -79,7 +75,7 @@ def local_collection_root_dir_key():
def default_local_collection_root_dir():
return Path(QgsApplication.qgisSettingsDirPath(),
- 'resource_sharing', 'collections')
+ 'resource_sharing', 'collections')
def local_collection_path(id=None):
@@ -119,13 +115,14 @@ def local_collection_path(id=None):
# Use repository name instead of hash
dir_name = '%s (%s)' % (sane_name, sane_repo_name)
path = lcPath / dir_name
- # Check if the "old" directory name exists (should eventuall be removed)
+ # Check if the "old" directory name exists
+ # (should eventuall be removed)
old_dir_name = '%s' % (id)
old_path = lcPath / old_dir_name
if old_path.exists():
try:
old_path.rename(path)
- except:
+ except Exception:
pass
return path