mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
WIP: Cleanup Upgrade 30 to 31
This commit is contained in:
parent
47e4b35e70
commit
f946f62db1
1 changed files with 0 additions and 74 deletions
|
@ -3,14 +3,9 @@
|
||||||
|
|
||||||
import configparser #To parse preference files.
|
import configparser #To parse preference files.
|
||||||
import io #To serialise the preference files afterwards.
|
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 UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
|
|
||||||
|
|
||||||
# a list of all legacy "Not Supported" quality profiles
|
# a list of all legacy "Not Supported" quality profiles
|
||||||
_OLD_NOT_SUPPORTED_PROFILES = [
|
_OLD_NOT_SUPPORTED_PROFILES = [
|
||||||
|
@ -130,7 +125,6 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
parser.write(output)
|
parser.write(output)
|
||||||
return [filename], [output.getvalue()]
|
return [filename], [output.getvalue()]
|
||||||
|
|
||||||
|
|
||||||
## Upgrades a container stack from version 3.0 to 3.1.
|
## Upgrades a container stack from version 3.0 to 3.1.
|
||||||
#
|
#
|
||||||
# \param serialised The serialised form of a container stack.
|
# \param serialised The serialised form of a container stack.
|
||||||
|
@ -172,71 +166,3 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
output = io.StringIO()
|
output = io.StringIO()
|
||||||
parser.write(output)
|
parser.write(output)
|
||||||
return [filename], [output.getvalue()]
|
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())
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue