From 16606611c5e8c03ebd3a456ba996e206e2c5246e Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Thu, 12 Sep 2024 15:55:06 +0200 Subject: [PATCH] Update changelog, tidy up code. --- CHANGELOG.md | 7 +++++++ qgis_hub_plugin/core/api_client.py | 2 +- qgis_hub_plugin/utilities/common.py | 7 ++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 172ad8b..2421771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,13 @@ Unreleased --> +## 0.2.0 - 2024-09-13 + +- Limit the name to be maximum 50 character +- Add filtering for 3D model and QGIS Layer Definition +- Add "add to QGIS" for layer definition +- Fix bug when resource give 404 + ## 0.1.2 - 2023-11-01 - Fix bug #85: failed to handle null thumbnail diff --git a/qgis_hub_plugin/core/api_client.py b/qgis_hub_plugin/core/api_client.py index f3f252b..d03c92b 100644 --- a/qgis_hub_plugin/core/api_client.py +++ b/qgis_hub_plugin/core/api_client.py @@ -19,7 +19,7 @@ def get_all_resources(force_update=False): return json.load(f) # TODO: download in the background - # hardcoded to get all resource, currently only ~160 + # hardcoded to get all resource, currently only ~227 url = f"{BASE_URL}?limit=1000&format=json" status = download_file(url=url, destination=response_file, force=force_update) if status and response_file.exists(): diff --git a/qgis_hub_plugin/utilities/common.py b/qgis_hub_plugin/utilities/common.py index 84df5ff..af85a49 100644 --- a/qgis_hub_plugin/utilities/common.py +++ b/qgis_hub_plugin/utilities/common.py @@ -23,11 +23,6 @@ def get_icon_path(icon_name: str) -> str: return os.path.join(DIR_PLUGIN_ROOT, "resources", "images", icon_name) -# def download_file(url: str, file_path: Path, force: bool = False): -# if not force and file_path.exists(): -# return - - def download_file( url: str, destination: Path, force: bool = True, timeout: int = 30000 ) -> Optional[str]: @@ -37,6 +32,8 @@ def download_file( Args: url (str): The URL of the file to download. destination (Path): The local path where the file should be saved. + force (bool): If true, the file will be downloaded even if it already exists. + Defaults to True. timeout (int): The timeout for the request in milliseconds. Defaults to 30000 (30 seconds). Returns: