|
@@ -0,0 +1,45 @@
|
|
|
+# Copyright (c) 2015 Ultimaker B.V.
|
|
|
+# Cura is released under the terms of the AGPLv3 or higher.
|
|
|
+
|
|
|
+from UM.VersionUpgrade import VersionUpgrade #Superclass of the plugin.
|
|
|
+
|
|
|
+from . import MachineInstance #To upgrade machine instances.
|
|
|
+from . import Preferences #To upgrade preferences.
|
|
|
+from . import Profile #To upgrade profiles.
|
|
|
+
|
|
|
+## Converts configuration from Cura 2.1's file formats to Cura 2.2's.
|
|
|
+#
|
|
|
+# It converts the machine instances, preferences and profiles.
|
|
|
+class VersionUpgrade21to22(VersionUpgrade):
|
|
|
+ ## Converts machine instances from format version 1 to version 2.
|
|
|
+ #
|
|
|
+ # \param serialised The serialised machine instance in version 1.
|
|
|
+ # \return The serialised machine instance in version 2, or None if the
|
|
|
+ # input was not of the correct format.
|
|
|
+ def upgradeMachineInstance(self, serialised):
|
|
|
+ machine_instance = MachineInstance.importVersion1(serialised)
|
|
|
+ if not machine_instance: #Invalid file format.
|
|
|
+ return None
|
|
|
+ return machine_instance.exportVersion2()
|
|
|
+
|
|
|
+ ## Converts preferences from format version 2 to version 3.
|
|
|
+ #
|
|
|
+ # \param serialised The serialised preferences file in version 2.
|
|
|
+ # \return The serialised preferences file in version 3, or None if the
|
|
|
+ # input was not of the correct format.
|
|
|
+ def upgradePreferences(self, serialised):
|
|
|
+ preferences = Preferences.importVersion2(serialised)
|
|
|
+ if not preferences: #Invalid file format.
|
|
|
+ return None
|
|
|
+ return preferences.exportVersion3()
|
|
|
+
|
|
|
+ ## Converts profiles from format version 1 to version 2.
|
|
|
+ #
|
|
|
+ # \param serialised The serialised profile in version 1.
|
|
|
+ # \return The serialised profile in version 2, or None if the input was
|
|
|
+ # not of the correct format.
|
|
|
+ def upgradeProfile(self, serialised):
|
|
|
+ profile = Profile.importVersion1(serialised)
|
|
|
+ if not profile: #Invalid file format.
|
|
|
+ return None
|
|
|
+ return profile.exportVersion2()
|