mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Add version upgrade for changed Redo Layer parameter of Pause script
This was changed from a number of layers to just a boolean for 1 or 0 layers. Contributes to issue CURA-7413.
This commit is contained in:
parent
aff28d821f
commit
89fc4c94bf
1 changed files with 21 additions and 0 deletions
|
@ -78,6 +78,27 @@ class VersionUpgrade462to47(VersionUpgrade):
|
|||
parser["metadata"] = {}
|
||||
parser["metadata"]["setting_version"] = "15"
|
||||
|
||||
# Update Pause at Height script parameters if present.
|
||||
if "post_processing_scripts" in parser["metadata"]:
|
||||
new_scripts_entries = []
|
||||
for script_str in parser["metadata"]["post_processing_scripts"].split("\n"):
|
||||
if not script_str:
|
||||
continue
|
||||
script_str = script_str.replace(r"\\\n", "\n").replace(r"\\\\", "\\\\") # Unescape escape sequences.
|
||||
script_parser = configparser.ConfigParser(interpolation=None)
|
||||
script_parser.optionxform = str # type: ignore # Don't transform the setting keys as they are case-sensitive.
|
||||
script_parser.read_string(script_str)
|
||||
if "PauseAtHeight" in script_parser:
|
||||
if "redo_layers" in script_parser["PauseAtHeight"]:
|
||||
script_parser["PauseAtHeight"]["redo_layer"] = str(int(script_parser["PauseAtHeight"]["redo_layers"]) > 0)
|
||||
del script_parser["PauseAtHeight"]["redo_layers"] # Has been renamed to without the S.
|
||||
script_io = io.StringIO()
|
||||
script_parser.write(script_io)
|
||||
script_str = script_io.getvalue()
|
||||
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)
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue