diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py index 3f49a3862d..f194fe8101 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py @@ -85,7 +85,7 @@ class Profile: if self._weight: config.set("general", "weight", self._weight) if self._machine_type_id: - translated_machine = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinters([self._machine_type_id])[0] + translated_machine = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinter(self._machine_type_id) config.set("general", "definition", translated_machine) else: config.set("general", "definition", "fdmprinter") diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py index e1632e0d85..71e5f9efbe 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py @@ -9,6 +9,11 @@ from . import MachineInstance # To upgrade machine instances. from . import Preferences #To upgrade preferences. from . import Profile # To upgrade profiles. +## How to translate printer names from the old version to the new. +_printer_translation = { + "ultimaker2plus": "ultimaker2_plus" +} + ## How to translate profile names from the old version to the new. _profile_translation = { "PLA": "generic_pla", @@ -16,6 +21,7 @@ _profile_translation = { "CPE": "generic_cpe" } +## How to translate setting names from the old version to the new. _setting_name_translation = { "speed_support_lines": "speed_support_infill" } @@ -69,16 +75,16 @@ class VersionUpgrade21to22(VersionUpgrade): return None return profile.export() - ## Translates printer names that have changed since the last version. + ## Translates a printer name that might have changed since the last + # version. # - # \param printers A list of printer names in the old version. - # \return The same list, but with printer names translated. + # \param printer A printer name in Cura 2.1. + # \return The name of the corresponding printer in Cura 2.2. @staticmethod - def translatePrinters(printers): - for index, printer in enumerate(printers): - if printer == "ultimaker2plus": - printers[index] = "ultimaker2_plus" - return printers + def translatePrinter(printer): + if printer in _printer_translation: + return _printer_translation[printer] + return printer #Doesn't need to be translated. ## Translates a built-in profile name that might have changed since the # last version.