From 712cebcdd2d11310199b62e5e2aa0a2ded712515 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 Jan 2020 11:43:07 +0100 Subject: [PATCH] Let 3mf workspace reader read from files per plugin CURA-6627 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 953980d0b7..7d4efa6e74 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -737,12 +737,20 @@ class ThreeMFWorkspaceReader(WorkspaceReader): def _loadMetadata(self, file_name) -> Dict[str, Dict[str, Any]]: archive = zipfile.ZipFile(file_name, "r") + + metadata_files = [name for name in archive.namelist() if name.endswith("plugin_metadata.json")] import json - try: - return json.loads(archive.open("Cura/plugin_metadata.json").read().decode("utf-8")) - except KeyError: - # The plugin_metadata.json file doesn't exist - return dict() + + result = dict() + + for metadata_file in metadata_files: + try: + plugin_id = metadata_file.split("/")[0] + result[plugin_id] = json.loads(archive.open("Cura/plugin_metadata.json").read().decode("utf-8")) + except Exception: + Logger.logException("w", "Unable to retrieve metadata for %s", metadata_file) + + return result def _processQualityChanges(self, global_stack): if self._machine_info.quality_changes_info is None: