CURA-5175 Add variants to the version upgrade.

Upgrade the version number in the variants and add the hardware_type
metadata.
This commit is contained in:
Diego Prado Gesto 2018-03-29 16:54:30 +02:00
parent b3d652839d
commit a5e38bb486
3 changed files with 28 additions and 1 deletions

View file

@ -149,6 +149,22 @@ class VersionUpgrade32to33(VersionUpgrade):
#Update version number.
parser["general"]["version"] = "3"
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]
## Upgrades a variant container to the new format.
def upgradeVariants(self, serialized, filename):
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
#Add the hardware type to the variants
if "metadata" in parser and "hardware_type" not in parser["metadata"]:
parser["metadata"]["hardware_type"] = "nozzle"
#Update version number.
parser["general"]["version"] = "3"
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]