Skip to content

Commit

Permalink
Merge pull request #326 from QGIS-Contribution/keyword-id
Browse files Browse the repository at this point in the history
Do not use reserved keyword id as a function parameter
  • Loading branch information
ptitjano authored Mar 19, 2024
2 parents ef79ae6 + cf20f19 commit 376fa06
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
24 changes: 12 additions & 12 deletions qgis_resource_sharing/gui/resource_sharing_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,25 +642,25 @@ def reload_collections_model(self):
"""Reload the collections model with the current collections."""
self.collections_model.clear()
installed_collections = self.collection_manager.get_installed_collections()
for id in config.COLLECTIONS:
collection_name = config.COLLECTIONS[id]["name"]
collection_author = config.COLLECTIONS[id]["author"]
collection_tags = config.COLLECTIONS[id]["tags"]
collection_description = config.COLLECTIONS[id]["description"]
collection_status = config.COLLECTIONS[id]["status"]
for collection_id in config.COLLECTIONS:
collection_name = config.COLLECTIONS[collection_id]["name"]
collection_author = config.COLLECTIONS[collection_id]["author"]
collection_tags = config.COLLECTIONS[collection_id]["tags"]
collection_description = config.COLLECTIONS[collection_id]["description"]
collection_status = config.COLLECTIONS[collection_id]["status"]
repository_name = ""
if "repository_name" in config.COLLECTIONS[id].keys():
repository_name = config.COLLECTIONS[id]["repository_name"]
if "repository_name" in config.COLLECTIONS[collection_id].keys():
repository_name = config.COLLECTIONS[collection_id]["repository_name"]
item = QStandardItem(collection_name + " (" + repository_name + ")")
item.setEditable(False)
item.setData(id, COLLECTION_ID_ROLE)
item.setData(collection_id, COLLECTION_ID_ROLE)
item.setData(collection_name, COLLECTION_NAME_ROLE)
item.setData(collection_description, COLLECTION_DESCRIPTION_ROLE)
item.setData(collection_author, COLLECTION_AUTHOR_ROLE)
item.setData(collection_tags, COLLECTION_TAGS_ROLE)
item.setData(collection_status, COLLECTION_STATUS_ROLE)
# Make installed collections stand out
if installed_collections and id in installed_collections.keys():
if installed_collections and collection_id in installed_collections.keys():
collectionFont = QFont()
collectionFont.setWeight(60)
item.setFont(collectionFont)
Expand Down Expand Up @@ -722,9 +722,9 @@ def filter_collections(self, text):
search = QRegExp(text, Qt.CaseInsensitive, QRegExp.RegExp)
self.collection_proxy.setFilterRegExp(search)

def show_collection_metadata(self, id):
def show_collection_metadata(self, collection_id):
"""Show the collection metadata given the ID."""
html = self.collection_manager.get_html(id)
html = self.collection_manager.get_html(collection_id)
self.web_view_details.setHtml(html)

def reject(self):
Expand Down
6 changes: 3 additions & 3 deletions qgis_resource_sharing/repository_handler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ def parse_metadata(self) -> List[Dict]:

return collections

def download_collection(self, id, register_name):
def download_collection(self, collection_id, register_name):
"""Download a collection given its ID.
:param id: The ID of the collection.
:type id: str
:param collection_id: The ID of the collection.
:type collection_id: str
:param register_name: The register name of the collection (the
section name of the collection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def fetch_metadata(self):

return True, message

def download_collection(self, id, register_name):
def download_collection(self, collection_id, register_name):
"""Download a collection given its ID.
:param id: The ID of the collection.
:type id: str
:param collection_id: The ID of the collection.
:type collection_id: str
:param register_name: The register name of the collection (the
section name of the collection)
Expand All @@ -58,7 +58,7 @@ def download_collection(self, id, register_name):
error_message = "Error: The collection does not exist in the " "repository."
return False, error_message

dest_dir = local_collection_path(id)
dest_dir = local_collection_path(collection_id)
if dest_dir.exists():
shutil.rmtree(str(dest_dir))
shutil.copytree(str(src_dir), str(dest_dir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def git_owner(self):
def git_repository(self):
return self._git_repository

def download_collection(self, id: str, register_name: str) -> tuple:
def download_collection(self, collection_id: str, register_name: str) -> tuple:
"""Download a collection given its ID.
For remote git repositories, we will clone the repository (or
pull if the repo is already cloned), and copy the collection to
the collections directory.
:param id: The ID of the collection.
:type id: str
:param collection_id: The ID of the collection.
:type collection_id: str
:param register_name: The register name of the collection (the
section name of the collection)
:type register_name: unicode
Expand Down Expand Up @@ -186,7 +186,7 @@ def download_collection(self, id: str, register_name: str) -> tuple:
error_message = "Error: The collection does not exist in the repository."
return False, error_message

dest_dir = local_collection_path(id)
dest_dir = local_collection_path(collection_id)
if dest_dir.exists():
# Remove the existing collection directory
shutil.rmtree(str(dest_dir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def can_handle(self):
return True
return False

def download_collection(self, id, register_name):
def download_collection(self, collection_id, register_name):
"""Download a collection given its ID.
For zip collection, we will download the zip, and extract the
collection to collections dir.
:param id: The ID of the collection.
:type id: str
:param collection_id: The ID of the collection.
:type collection_id: str
:param register_name: The register name of the collection (the
section name of the collection)
Expand All @@ -54,7 +54,7 @@ def download_collection(self, id, register_name):
zip_file.close()

zf = ZipFile(zip_file.fileName())
zf.extractall(path=local_collection_path(id))
zf.extractall(path=local_collection_path(collection_id))
return True, None

def file_url(self, relative_path):
Expand Down

0 comments on commit 376fa06

Please sign in to comment.