diff --git a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py index d7b2c1a001..a88ff5ac1c 100644 --- a/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py +++ b/plugins/VersionUpgrade/VersionUpgrade30to31/VersionUpgrade30to31.py @@ -3,14 +3,9 @@ import configparser #To parse preference files. import io #To serialise the preference files afterwards. -import os -from urllib.parse import quote_plus -from UM.Resources import Resources from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. -from cura.CuraApplication import CuraApplication - # a list of all legacy "Not Supported" quality profiles _OLD_NOT_SUPPORTED_PROFILES = [ @@ -130,7 +125,6 @@ class VersionUpgrade30to31(VersionUpgrade): parser.write(output) return [filename], [output.getvalue()] - ## Upgrades a container stack from version 3.0 to 3.1. # # \param serialised The serialised form of a container stack. @@ -172,71 +166,3 @@ class VersionUpgrade30to31(VersionUpgrade): output = io.StringIO() parser.write(output) return [filename], [output.getvalue()] - - def _getSingleExtrusionMachineQualityChanges(self, quality_changes_container): - quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer) - quality_changes_containers = [] - - for item in os.listdir(quality_changes_dir): - file_path = os.path.join(quality_changes_dir, item) - if not os.path.isfile(file_path): - continue - - parser = configparser.ConfigParser(interpolation = None) - try: - parser.read([file_path]) - except: - # skip, it is not a valid stack file - continue - - if not parser.has_option("metadata", "type"): - continue - if "quality_changes" != parser["metadata"]["type"]: - continue - - if not parser.has_option("general", "name"): - continue - if quality_changes_container["general"]["name"] != parser["general"]["name"]: - continue - - quality_changes_containers.append(parser) - - return quality_changes_containers - - def _createExtruderQualityChangesForSingleExtrusionMachine(self, filename, global_quality_changes): - suffix = "_" + quote_plus(global_quality_changes["general"]["name"].lower()) - machine_name = os.path.os.path.basename(filename).replace(".inst.cfg", "").replace(suffix, "") - - # Why is this here?! - # When we load a .curaprofile file the deserialize will trigger a version upgrade, creating a dangling file. - # This file can be recognized by it's lack of a machine name in the target filename. - # So when we detect that situation here, we don't create the file and return. - if machine_name == "": - return - - new_filename = machine_name + "_" + "fdmextruder" + suffix - - extruder_quality_changes_parser = configparser.ConfigParser(interpolation = None) - extruder_quality_changes_parser.add_section("general") - extruder_quality_changes_parser["general"]["version"] = str(2) - extruder_quality_changes_parser["general"]["name"] = global_quality_changes["general"]["name"] - extruder_quality_changes_parser["general"]["definition"] = global_quality_changes["general"]["definition"] - - # check renamed definition - if extruder_quality_changes_parser["general"]["definition"] in _RENAMED_DEFINITION_DICT: - extruder_quality_changes_parser["general"]["definition"] = _RENAMED_DEFINITION_DICT[extruder_quality_changes_parser["general"]["definition"]] - - extruder_quality_changes_parser.add_section("metadata") - extruder_quality_changes_parser["metadata"]["quality_type"] = global_quality_changes["metadata"]["quality_type"] - extruder_quality_changes_parser["metadata"]["type"] = global_quality_changes["metadata"]["type"] - extruder_quality_changes_parser["metadata"]["setting_version"] = str(4) - extruder_quality_changes_parser["metadata"]["extruder"] = "fdmextruder" - - extruder_quality_changes_output = io.StringIO() - extruder_quality_changes_parser.write(extruder_quality_changes_output) - extruder_quality_changes_filename = quote_plus(new_filename) + ".inst.cfg" - - quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer) - - with open(os.path.join(quality_changes_dir, extruder_quality_changes_filename), "w", encoding = "utf-8") as f: - f.write(extruder_quality_changes_output.getvalue())