Browse Source

Express getConfigurationTypeFromSerialized as function of its parent

This prevents code duplication a bit and allows us to make it a classmethod.

Contributes to issue CURA-4243.
Ghostkeeper 7 years ago
parent
commit
e48b151d40
1 changed files with 5 additions and 9 deletions
  1. 5 9
      cura/Settings/GlobalStack.py

+ 5 - 9
cura/Settings/GlobalStack.py

@@ -43,15 +43,11 @@ class GlobalStack(CuraContainerStack):
     def getLoadingPriority(cls) -> int:
         return 2
 
-    def getConfigurationTypeFromSerialized(self, serialized: str) -> Optional[str]:
-        configuration_type = None
-        try:
-            parser = self._readAndValidateSerialized(serialized)
-            configuration_type = parser["metadata"].get("type")
-            if configuration_type == "machine":
-                configuration_type = "machine_stack"
-        except Exception as e:
-            Logger.log("e", "Could not get configuration type: %s", e)
+    @classmethod
+    def getConfigurationTypeFromSerialized(cls, serialized: str) -> Optional[str]:
+        configuration_type = super().getConfigurationTypeFromSerialized(serialized)
+        if configuration_type == "machine":
+            return "machine_stack"
         return configuration_type
 
     ##  Add an extruder to the list of extruders of this stack.