diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py | 75 | ||||
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py | 35 |
2 files changed, 107 insertions, 3 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py index a6e541be6d..0388c8820a 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py @@ -10,6 +10,7 @@ _renamed_themes = { "cura": "cura-light" } + class VersionUpgrade27to30(VersionUpgrade): ## Gets the version number from a CFG file in Uranium's 2.7 format. # @@ -43,14 +44,84 @@ class VersionUpgrade27to30(VersionUpgrade): parser["general"]["version"] = "5" if "metadata" not in parser: parser["metadata"] = {} - parser["metadata"]["setting_version"] = "2" + parser["metadata"]["setting_version"] = "3" #Renamed themes. if "theme" in parser["general"]: if parser["general"]["theme"] in _renamed_themes: parser["general"]["theme"] = _renamed_themes[parser["general"]["theme"]] + # Renamed settings for skin pre-shrink settings + if parser.has_section("general") and "visible_settings" in parser["general"]: + visible_settings = parser["general"]["visible_settings"].split(";") + new_visible_settings = [] + renamed_skin_preshrink_names = {"expand_upper_skins": "top_skin_expand_distance", + "expand_lower_skins": "bottom_skin_expand_distance"} + for setting in visible_settings: + if setting == "expand_skins_into_infill": + continue # this one is removed + if setting in renamed_skin_preshrink_names: + new_visible_settings.append(renamed_skin_preshrink_names[setting]) + continue #Don't add the original. + new_visible_settings.append(setting) #No special handling, so just add the original visible setting back. + parser["general"]["visible_settings"] = ";".join(new_visible_settings) + + # Re-serialise the file. + output = io.StringIO() + parser.write(output) + return [filename], [output.getvalue()] + + ## Upgrades the given instance container file from version 2.7 to 3.0. + # + # \param serialised The serialised form of the container file. + # \param filename The name of the file to upgrade. + def upgradeOtherContainer(self, serialised, filename): + parser = configparser.ConfigParser(interpolation=None) + parser.read_string(serialised) + + # Update the skin pre-shrink settings: + # - Remove the old ones + # - Do not add the new ones. The default values will be used for them. + if parser.has_section("values"): + for remove_key in ["expand_skins_into_infill", "expand_upper_skins", "expand_lower_skins"]: + if remove_key in parser["values"]: + del parser["values"][remove_key] + + for each_section in ("general", "metadata"): + if not parser.has_section(each_section): + parser.add_section(each_section) + + # Update version numbers + parser["general"]["version"] = "2" + parser["metadata"]["setting_version"] = "3" + + # Re-serialise the file. + output = io.StringIO() + parser.write(output) + return [filename], [output.getvalue()] + + ## Upgrades a container stack from version 2.7 to 3.0. + # + # \param serialised The serialised form of a container stack. + # \param filename The name of the file to upgrade. + def upgradeStack(self, serialised, filename): + parser = configparser.ConfigParser(interpolation=None) + parser.read_string(serialised) + + for each_section in ("general", "metadata"): + if not parser.has_section(each_section): + parser.add_section(each_section) + + # Update version numbers + if "general" not in parser: + parser["general"] = {} + parser["general"]["version"] = "3" + + if "metadata" not in parser: + parser["metadata"] = {} + parser["metadata"]["setting_version"] = "3" + # Re-serialise the file. output = io.StringIO() parser.write(output) - return [filename], [output.getvalue()]
\ No newline at end of file + return [filename], [output.getvalue()] diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py b/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py index 73e1246360..ece6cb83f2 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py @@ -9,13 +9,46 @@ def getMetaData(): return { "version_upgrade": { # From To Upgrade function - ("preferences", 4000002): ("preferences", 5000002, upgrade.upgradePreferences), + ("preferences", 4000002): ("preferences", 5000003, upgrade.upgradePreferences), + + ("machine_stack", 3000002): ("machine_stack", 3000003, upgrade.upgradeStack), + ("extruder_train", 3000002): ("extruder_train", 3000003, upgrade.upgradeStack), + + ("quality_changes", 2000002): ("quality_changes", 2000003, upgrade.upgradeOtherContainer), + ("user", 2000002): ("user", 2000003, upgrade.upgradeOtherContainer), + ("quality", 2000002): ("quality", 2000003, upgrade.upgradeOtherContainer), + ("definition_changes", 2000002): ("definition_changes", 2000003, upgrade.upgradeOtherContainer), + ("variant", 2000002): ("variant", 2000003, upgrade.upgradeOtherContainer) }, "sources": { "preferences": { "get_version": upgrade.getCfgVersion, "location": {"."} }, + "machine_stack": { + "get_version": upgrade.getCfgVersion, + "location": {"./machine_instances"} + }, + "extruder_train": { + "get_version": upgrade.getCfgVersion, + "location": {"./extruders"} + }, + "quality_changes": { + "get_version": upgrade.getCfgVersion, + "location": {"./quality"} + }, + "user": { + "get_version": upgrade.getCfgVersion, + "location": {"./user"} + }, + "definition_changes": { + "get_version": upgrade.getCfgVersion, + "location": {"./definition_changes"} + }, + "variant": { + "get_version": upgrade.getCfgVersion, + "location": {"./variants"} + } } } |