Browse Source

Move _machines_with_machine_quality to VersionUpgrade21to22

It's going to need to be used by the upgrader of machine instances as well, that's why.

Contributes to issue CURA-844.
Ghostkeeper 8 years ago
parent
commit
36f84017cf

+ 1 - 12
plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py

@@ -7,17 +7,6 @@ import io #To write config files to strings as if they were files.
 
 import UM.VersionUpgrade
 
-##  Which machines have material-specific profiles in the new version?
-#
-#   These are the 2.1 machine identities with "has_machine_materials": true in
-#   their definitions in Cura 2.2. So these are the machines for which profiles
-#   need to split into multiple profiles, one for each material.
-#
-#   This should contain the definition as they are stated in the profiles. The
-#   inheritance structure cannot be found at this stage, since the definitions
-#   may have changed in later versions than 2.2.
-_machines_with_machine_quality = {"ultimaker2plus", "ultimaker2_extended_plus"}
-
 ##  The materials in Cura 2.2.
 #
 #   This is required to know how to split old profiles if the old machine didn't
@@ -153,7 +142,7 @@ class Profile:
             config.set("metadata", "material", self._material_name)
             filenames.append(self._filename)
             configs.append(config)
-        elif self._type != "material" and self._machine_type_id in _machines_with_machine_quality:
+        elif self._type != "material" and self._machine_type_id in VersionUpgrade21to22.machines_with_machine_quality():
             #Split this profile into multiple profiles, one for each material.
             for material_id in _new_materials:
                 filenames.append("{profile}_{material}".format(profile = self._filename, material = material_id))

+ 18 - 0
plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py

@@ -9,6 +9,17 @@ from . import MachineInstance # To upgrade machine instances.
 from . import Preferences #To upgrade preferences.
 from . import Profile # To upgrade profiles.
 
+##  Which machines have material-specific profiles in the new version?
+#
+#   These are the 2.1 machine identities with "has_machine_materials": true in
+#   their definitions in Cura 2.2. So these are the machines for which profiles
+#   need to split into multiple profiles, one for each material.
+#
+#   This should contain the definition as they are stated in the profiles. The
+#   inheritance structure cannot be found at this stage, since the definitions
+#   may have changed in later versions than 2.2.
+_machines_with_machine_quality = {"ultimaker2plus", "ultimaker2_extended_plus"}
+
 ##  How to translate printer names from the old version to the new.
 _printer_translations = {
     "ultimaker2plus": "ultimaker2_plus"
@@ -77,6 +88,13 @@ class VersionUpgrade21to22(VersionUpgrade):
         parser.read_string(serialised)
         return int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
 
+    ##  Gets a set of the machines which now have per-material quality profiles.
+    #
+    #   \return A set of machine identifiers.
+    @staticmethod
+    def machines_with_machine_quality(self):
+        return _machines_with_machine_quality
+
     ##  Converts machine instances from format version 1 to version 2.
     #
     #   \param serialised The serialised machine instance in version 1.