|
@@ -2,10 +2,17 @@
|
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
|
|
import configparser
|
|
|
-from typing import Tuple, List
|
|
|
+from typing import Tuple, List, Dict
|
|
|
import io
|
|
|
from UM.VersionUpgrade import VersionUpgrade
|
|
|
|
|
|
+
|
|
|
+# Renamed definition files
|
|
|
+_RENAMED_DEFINITION_DICT = {
|
|
|
+ "dagoma_discoeasy200": "dagoma_discoeasy200_bicolor",
|
|
|
+} # type: Dict[str, str]
|
|
|
+
|
|
|
+
|
|
|
class VersionUpgrade462to47(VersionUpgrade):
|
|
|
def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
|
|
"""
|
|
@@ -71,6 +78,10 @@ class VersionUpgrade462to47(VersionUpgrade):
|
|
|
ironing_inset = "=(" + ironing_inset + ")" + correction
|
|
|
parser["values"]["ironing_inset"] = ironing_inset
|
|
|
|
|
|
+ # Check renamed definitions
|
|
|
+ if "definition" in parser["general"] and parser["general"]["definition"] in _RENAMED_DEFINITION_DICT:
|
|
|
+ parser["general"]["definition"] = _RENAMED_DEFINITION_DICT[parser["general"]["definition"]]
|
|
|
+
|
|
|
result = io.StringIO()
|
|
|
parser.write(result)
|
|
|
return [filename], [result.getvalue()]
|
|
@@ -130,7 +141,9 @@ class VersionUpgrade462to47(VersionUpgrade):
|
|
|
script_str = script_str.replace("\\\\", r"\\\\").replace("\n", r"\\\n") # Escape newlines because configparser sees those as section delimiters.
|
|
|
new_scripts_entries.append(script_str)
|
|
|
parser["metadata"]["post_processing_scripts"] = "\n".join(new_scripts_entries)
|
|
|
-
|
|
|
+ # check renamed definition
|
|
|
+ if parser.has_option("containers", "7") and parser["containers"]["7"] in _RENAMED_DEFINITION_DICT:
|
|
|
+ parser["containers"]["7"] = _RENAMED_DEFINITION_DICT[parser["containers"]["7"]]
|
|
|
result = io.StringIO()
|
|
|
parser.write(result)
|
|
|
return [filename], [result.getvalue()]
|