From 6c6187ab01709c3af8380adf5a6418e78f046dbc Mon Sep 17 00:00:00 2001 From: andershol Date: Wed, 10 Jun 2026 00:53:38 +0200 Subject: [PATCH 1/2] Reduce indent of generate_cache_entry_from_package_xml --- AddonCatalogCacheCreator.py | 90 ++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/AddonCatalogCacheCreator.py b/AddonCatalogCacheCreator.py index b663aeea..45a05ab5 100644 --- a/AddonCatalogCacheCreator.py +++ b/AddonCatalogCacheCreator.py @@ -317,52 +317,52 @@ def generate_cache_entry_from_package_xml( return None relative_icon_path = self.get_icon_from_metadata(metadata) - if relative_icon_path is not None: - absolute_icon_path = os.path.join( - os.path.dirname(path_to_package_xml), relative_icon_path - ) - if os.path.exists(absolute_icon_path): - icon_data_is_good = True - with open(absolute_icon_path, "rb") as f: + if relative_icon_path is None: + return cache_entry + + absolute_icon_path = os.path.join(os.path.dirname(path_to_package_xml), relative_icon_path) + if not os.path.exists(absolute_icon_path): + self.icon_errors[metadata.name] = {"bad_icon_path": relative_icon_path} + print(f"ERROR: Could not find icon file {absolute_icon_path}") + return cache_entry + + icon_data = None + with open(absolute_icon_path, "rb") as f: + try: + icon_data = f.read() + except IOError as e: + print(f"ERROR: IO Error while reading icon file {absolute_icon_path}") + print(e) + except Exception as e: + print(f"ERROR: Unknown error while reading icon file {absolute_icon_path}") + print(e) + + if icon_data is not None: + if absolute_icon_path.lower().endswith(".svg"): + try: + if not icon_utils.is_svg_bytes(icon_data): + self.icon_errors[metadata.name] = { + "valid_icon_path": relative_icon_path, + "error_message": "SVG file does not have valid XML header", + } + icon_data = None + except icon_utils.BadIconData as e: + self.icon_errors[metadata.name] = { + "valid_icon_path": relative_icon_path, + "error_message": str(e), + } icon_data = None - try: - icon_data = f.read() - except IOError as e: - print(f"ERROR: IO Error while reading icon file {absolute_icon_path}") - print(e) - icon_data_is_good = False - except Exception as e: - print(f"ERROR: Unknown error while reading icon file {absolute_icon_path}") - print(e) - icon_data_is_good = False - if icon_data is not None: - if absolute_icon_path.lower().endswith(".svg"): - try: - if not icon_utils.is_svg_bytes(icon_data): - self.icon_errors[metadata.name] = { - "valid_icon_path": relative_icon_path, - "error_message": "SVG file does not have valid XML header", - } - icon_data_is_good = False - except icon_utils.BadIconData as e: - self.icon_errors[metadata.name] = { - "valid_icon_path": relative_icon_path, - "error_message": str(e), - } - icon_data_is_good = False - elif absolute_icon_path.lower().endswith(".png"): - if icon_utils.png_has_duplicate_iccp(icon_data): - self.icon_errors[metadata.name] = { - "valid_icon_path": relative_icon_path, - "error_message": "PNG data has duplicate iCCP chunk", - } - icon_data_is_good = False - - if icon_data_is_good: - cache_entry.icon_data = base64.b64encode(icon_data).decode("utf-8") - else: - self.icon_errors[metadata.name] = {"bad_icon_path": relative_icon_path} - print(f"ERROR: Could not find icon file {absolute_icon_path}") + elif absolute_icon_path.lower().endswith(".png"): + if icon_utils.png_has_duplicate_iccp(icon_data): + self.icon_errors[metadata.name] = { + "valid_icon_path": relative_icon_path, + "error_message": "PNG data has duplicate iCCP chunk", + } + icon_data = None + + if icon_data is not None: + cache_entry.icon_data = base64.b64encode(icon_data).decode("utf-8") + return cache_entry def create_local_copy_of_single_addon_with_git( From 835f3b1f28372c592ff416ccb2bca7ec33fbae22 Mon Sep 17 00:00:00 2001 From: andershol Date: Wed, 10 Jun 2026 01:11:11 +0200 Subject: [PATCH 2/2] Enable override of addon icons and add aliases for the largest icons --- AddonCatalogCacheCreator.py | 12 +++- IconAliases/AIGenFurniture-e5d2e146.svg | 30 ++++++++ IconAliases/Assembly3-139af500.svg | 68 +++++++++++++++++++ IconAliases/BillOfMaterials-08c04065.svg | 59 ++++++++++++++++ IconAliases/Cubinets-c7d1e95b.svg | 22 ++++++ IconAliases/DFM-557ecf6f.svg | 56 +++++++++++++++ IconAliases/DesignSPHysics-4e83d58b.svg | 42 ++++++++++++ IconAliases/Detessellate-ce7a7cf7.svg | 33 +++++++++ IconAliases/EM-3a2d1d01.svg | 36 ++++++++++ IconAliases/EasyProfileFrame-249ff536.svg | 16 +++++ IconAliases/FreeGrid-92890ab7.svg | 15 ++++ .../Freecad-Built-in-themes-beta-a7b3dad5.svg | 30 ++++++++ IconAliases/MOOC-62b8f18a.svg | 7 ++ IconAliases/Machines-7bd6be2a.svg | 47 +++++++++++++ IconAliases/MakerWorkbench-e11e1a1b.svg | 16 +++++ IconAliases/NikraDAP-991b96b7.svg | 14 ++++ IconAliases/Ondsel-Lens-9595372d.svg | 3 + IconAliases/PieMenu-811dbfa2.svg | 20 ++++++ IconAliases/Reinforcement-46873d9f.svg | 26 +++++++ IconAliases/Road-ff13f8b3.svg | 5 ++ IconAliases/TitleBlock-bc876961.svg | 30 ++++++++ IconAliases/WebTools-95d3c71b.svg | 36 ++++++++++ IconAliases/boltsfc-0cd39929.svg | 12 ++++ IconAliases/frame-4f6a2a3e.svg | 5 ++ IconAliases/freecad-xr-workbench-05cd4961.svg | 9 +++ IconAliases/freecad.gears-5c1cf364.svg | 35 ++++++++++ ...eecad.optics_design_workbench-d74baf9d.svg | 3 + IconAliases/woodworking-c448e07d.svg | 9 +++ 28 files changed, 694 insertions(+), 2 deletions(-) create mode 100644 IconAliases/AIGenFurniture-e5d2e146.svg create mode 100644 IconAliases/Assembly3-139af500.svg create mode 100644 IconAliases/BillOfMaterials-08c04065.svg create mode 100644 IconAliases/Cubinets-c7d1e95b.svg create mode 100644 IconAliases/DFM-557ecf6f.svg create mode 100644 IconAliases/DesignSPHysics-4e83d58b.svg create mode 100644 IconAliases/Detessellate-ce7a7cf7.svg create mode 100644 IconAliases/EM-3a2d1d01.svg create mode 100644 IconAliases/EasyProfileFrame-249ff536.svg create mode 100644 IconAliases/FreeGrid-92890ab7.svg create mode 100644 IconAliases/Freecad-Built-in-themes-beta-a7b3dad5.svg create mode 100644 IconAliases/MOOC-62b8f18a.svg create mode 100644 IconAliases/Machines-7bd6be2a.svg create mode 100644 IconAliases/MakerWorkbench-e11e1a1b.svg create mode 100644 IconAliases/NikraDAP-991b96b7.svg create mode 100644 IconAliases/Ondsel-Lens-9595372d.svg create mode 100644 IconAliases/PieMenu-811dbfa2.svg create mode 100644 IconAliases/Reinforcement-46873d9f.svg create mode 100644 IconAliases/Road-ff13f8b3.svg create mode 100644 IconAliases/TitleBlock-bc876961.svg create mode 100644 IconAliases/WebTools-95d3c71b.svg create mode 100644 IconAliases/boltsfc-0cd39929.svg create mode 100644 IconAliases/frame-4f6a2a3e.svg create mode 100644 IconAliases/freecad-xr-workbench-05cd4961.svg create mode 100644 IconAliases/freecad.gears-5c1cf364.svg create mode 100644 IconAliases/freecad.optics_design_workbench-d74baf9d.svg create mode 100644 IconAliases/woodworking-c448e07d.svg diff --git a/AddonCatalogCacheCreator.py b/AddonCatalogCacheCreator.py index 45a05ab5..615e6380 100644 --- a/AddonCatalogCacheCreator.py +++ b/AddonCatalogCacheCreator.py @@ -266,7 +266,7 @@ def generate_cache_entry( path_to_package_xml = self.find_file("package.xml", addon_id, index, catalog_entry) cache_entry = None if path_to_package_xml and os.path.exists(path_to_package_xml): - cache_entry = self.generate_cache_entry_from_package_xml(path_to_package_xml) + cache_entry = self.generate_cache_entry_from_package_xml(addon_id, path_to_package_xml) path_to_requirements = self.find_file("requirements.txt", addon_id, index, catalog_entry) if path_to_requirements and os.path.exists(path_to_requirements): @@ -300,7 +300,7 @@ def generate_cache_entry( return cache_entry def generate_cache_entry_from_package_xml( - self, path_to_package_xml: str + self, addon_id: str, path_to_package_xml: str ) -> Optional[AddonCatalog.CatalogEntryMetadata]: cache_entry = AddonCatalog.CatalogEntryMetadata() with open(path_to_package_xml, "r", encoding="utf-8") as f: @@ -361,6 +361,14 @@ def generate_cache_entry_from_package_xml( icon_data = None if icon_data is not None: + base_path = os.path.dirname(os.path.realpath(__file__)) + svg_name = addon_id + "-" + hashlib.sha1(icon_data).hexdigest()[:8] + ".svg" + path = os.path.join(base_path, "IconAliases", svg_name) + if os.path.exists(path): + with open(path, "rb") as f: + icon_data = f.read() + if len(icon_data) > 10000: + print(f'WARNING: icon_data is long, {len(icon_data):,} bytes. Add "{svg_name}"') cache_entry.icon_data = base64.b64encode(icon_data).decode("utf-8") return cache_entry diff --git a/IconAliases/AIGenFurniture-e5d2e146.svg b/IconAliases/AIGenFurniture-e5d2e146.svg new file mode 100644 index 00000000..502dc42b --- /dev/null +++ b/IconAliases/AIGenFurniture-e5d2e146.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/Assembly3-139af500.svg b/IconAliases/Assembly3-139af500.svg new file mode 100644 index 00000000..8b357fa8 --- /dev/null +++ b/IconAliases/Assembly3-139af500.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/BillOfMaterials-08c04065.svg b/IconAliases/BillOfMaterials-08c04065.svg new file mode 100644 index 00000000..afb23ff0 --- /dev/null +++ b/IconAliases/BillOfMaterials-08c04065.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/Cubinets-c7d1e95b.svg b/IconAliases/Cubinets-c7d1e95b.svg new file mode 100644 index 00000000..8155ba86 --- /dev/null +++ b/IconAliases/Cubinets-c7d1e95b.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/DFM-557ecf6f.svg b/IconAliases/DFM-557ecf6f.svg new file mode 100644 index 00000000..8f8c458d --- /dev/null +++ b/IconAliases/DFM-557ecf6f.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/DesignSPHysics-4e83d58b.svg b/IconAliases/DesignSPHysics-4e83d58b.svg new file mode 100644 index 00000000..5152f4c6 --- /dev/null +++ b/IconAliases/DesignSPHysics-4e83d58b.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/Detessellate-ce7a7cf7.svg b/IconAliases/Detessellate-ce7a7cf7.svg new file mode 100644 index 00000000..2c575abd --- /dev/null +++ b/IconAliases/Detessellate-ce7a7cf7.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/EM-3a2d1d01.svg b/IconAliases/EM-3a2d1d01.svg new file mode 100644 index 00000000..ee0a4542 --- /dev/null +++ b/IconAliases/EM-3a2d1d01.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/EasyProfileFrame-249ff536.svg b/IconAliases/EasyProfileFrame-249ff536.svg new file mode 100644 index 00000000..5958e98a --- /dev/null +++ b/IconAliases/EasyProfileFrame-249ff536.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/IconAliases/FreeGrid-92890ab7.svg b/IconAliases/FreeGrid-92890ab7.svg new file mode 100644 index 00000000..eda4f965 --- /dev/null +++ b/IconAliases/FreeGrid-92890ab7.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/IconAliases/Freecad-Built-in-themes-beta-a7b3dad5.svg b/IconAliases/Freecad-Built-in-themes-beta-a7b3dad5.svg new file mode 100644 index 00000000..e97a4b9e --- /dev/null +++ b/IconAliases/Freecad-Built-in-themes-beta-a7b3dad5.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/MOOC-62b8f18a.svg b/IconAliases/MOOC-62b8f18a.svg new file mode 100644 index 00000000..a9016d7c --- /dev/null +++ b/IconAliases/MOOC-62b8f18a.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/IconAliases/Machines-7bd6be2a.svg b/IconAliases/Machines-7bd6be2a.svg new file mode 100644 index 00000000..88837d0b --- /dev/null +++ b/IconAliases/Machines-7bd6be2a.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/MakerWorkbench-e11e1a1b.svg b/IconAliases/MakerWorkbench-e11e1a1b.svg new file mode 100644 index 00000000..339f4353 --- /dev/null +++ b/IconAliases/MakerWorkbench-e11e1a1b.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/IconAliases/NikraDAP-991b96b7.svg b/IconAliases/NikraDAP-991b96b7.svg new file mode 100644 index 00000000..3ee74084 --- /dev/null +++ b/IconAliases/NikraDAP-991b96b7.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/IconAliases/Ondsel-Lens-9595372d.svg b/IconAliases/Ondsel-Lens-9595372d.svg new file mode 100644 index 00000000..7335de73 --- /dev/null +++ b/IconAliases/Ondsel-Lens-9595372d.svg @@ -0,0 +1,3 @@ + + + diff --git a/IconAliases/PieMenu-811dbfa2.svg b/IconAliases/PieMenu-811dbfa2.svg new file mode 100644 index 00000000..31ae4093 --- /dev/null +++ b/IconAliases/PieMenu-811dbfa2.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/Reinforcement-46873d9f.svg b/IconAliases/Reinforcement-46873d9f.svg new file mode 100644 index 00000000..826e9faf --- /dev/null +++ b/IconAliases/Reinforcement-46873d9f.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/Road-ff13f8b3.svg b/IconAliases/Road-ff13f8b3.svg new file mode 100644 index 00000000..46ca4e84 --- /dev/null +++ b/IconAliases/Road-ff13f8b3.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/IconAliases/TitleBlock-bc876961.svg b/IconAliases/TitleBlock-bc876961.svg new file mode 100644 index 00000000..77b86dc7 --- /dev/null +++ b/IconAliases/TitleBlock-bc876961.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/WebTools-95d3c71b.svg b/IconAliases/WebTools-95d3c71b.svg new file mode 100644 index 00000000..df7c9ad0 --- /dev/null +++ b/IconAliases/WebTools-95d3c71b.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/boltsfc-0cd39929.svg b/IconAliases/boltsfc-0cd39929.svg new file mode 100644 index 00000000..4508d4ed --- /dev/null +++ b/IconAliases/boltsfc-0cd39929.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/IconAliases/frame-4f6a2a3e.svg b/IconAliases/frame-4f6a2a3e.svg new file mode 100644 index 00000000..8f2c43c5 --- /dev/null +++ b/IconAliases/frame-4f6a2a3e.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/IconAliases/freecad-xr-workbench-05cd4961.svg b/IconAliases/freecad-xr-workbench-05cd4961.svg new file mode 100644 index 00000000..368c0656 --- /dev/null +++ b/IconAliases/freecad-xr-workbench-05cd4961.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/IconAliases/freecad.gears-5c1cf364.svg b/IconAliases/freecad.gears-5c1cf364.svg new file mode 100644 index 00000000..7bccd839 --- /dev/null +++ b/IconAliases/freecad.gears-5c1cf364.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IconAliases/freecad.optics_design_workbench-d74baf9d.svg b/IconAliases/freecad.optics_design_workbench-d74baf9d.svg new file mode 100644 index 00000000..39d81e66 --- /dev/null +++ b/IconAliases/freecad.optics_design_workbench-d74baf9d.svg @@ -0,0 +1,3 @@ + + + diff --git a/IconAliases/woodworking-c448e07d.svg b/IconAliases/woodworking-c448e07d.svg new file mode 100644 index 00000000..39278014 --- /dev/null +++ b/IconAliases/woodworking-c448e07d.svg @@ -0,0 +1,9 @@ + + + + + + + + +