Move the getCfgVersion to base version upgrade

They can still be overridden, but in the current situation they were
all the same...
This commit is contained in:
Jaime van Kessel 2020-04-22 11:30:35 +02:00
parent ad6f837f44
commit de7e3f824d
No known key found for this signature in database
GPG key ID: 3710727397403C91
15 changed files with 7 additions and 209 deletions

View file

@ -64,29 +64,12 @@ _renamed_quality_profiles = {
"um3_bb0.8_TPU_Not_Supported_Superdraft_Quality": "um3_bb0.8_TPU_Superdraft_Print",
} # type: Dict[str, str]
## A collection of functions that convert the configuration of the user in Cura
# 2.6 to a configuration for Cura 2.7.
#
# All of these methods are essentially stateless.
class VersionUpgrade26to27(VersionUpgrade):
## Gets the version number from a CFG file in Uranium's 2.6 format.
#
# Since the format may change, this is implemented for the 2.6 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: str) -> int:
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 a preferences file from version 2.6 to 2.7.
#
# \param serialised The serialised form of a preferences file.