mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00

The functionality is more or less the same, so in an attempt to keep people's profiles as similar as possible we translate this setting to the newer implementation.
53 lines
No EOL
2.2 KiB
Python
53 lines
No EOL
2.2 KiB
Python
# Copyright (c) 2018 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
import configparser #To parse preference files.
|
|
import io #To serialise the preference files afterwards.
|
|
|
|
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
|
|
|
|
_renamed_settings = {
|
|
"infill_hollow": "infill_support_enabled"
|
|
}
|
|
|
|
## Upgrades configurations from the state they were in at version 3.3 to the
|
|
# state they should be in at version 3.4.
|
|
class VersionUpgrade33to34(VersionUpgrade):
|
|
|
|
## Gets the version number from a CFG file in Uranium's 3.3 format.
|
|
#
|
|
# Since the format may change, this is implemented for the 3.3 format only
|
|
# and needs to be included in the version upgrade system rather than
|
|
# globally in Uranium.
|
|
#
|
|
# \param serialised The serialised form of a CFG file.
|
|
# \return The version number stored in the CFG file.
|
|
# \raises ValueError The format of the version number in the file is
|
|
# incorrect.
|
|
# \raises KeyError The format of the file is incorrect.
|
|
def getCfgVersion(self, serialised):
|
|
parser = configparser.ConfigParser(interpolation = None)
|
|
parser.read_string(serialised)
|
|
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
|
|
setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
|
|
return format_version * 1000000 + setting_version
|
|
|
|
## Upgrades instance containers to have the new version
|
|
# number.
|
|
def upgradeInstanceContainer(self, serialized, filename):
|
|
parser = configparser.ConfigParser(interpolation = None)
|
|
parser.read_string(serialized)
|
|
|
|
# Update version number.
|
|
parser["general"]["version"] = "4"
|
|
|
|
#Renamed settings.
|
|
if "values" in parser:
|
|
for original, replacement in _renamed_settings.items():
|
|
if original in parser["value"]:
|
|
parser["value"][replacement] = parser["value"][original]
|
|
del parser["value"][original]
|
|
|
|
result = io.StringIO()
|
|
parser.write(result)
|
|
return [filename], [result.getvalue()] |