Move _machines_with_machine_quality to VersionUpgrade21to22

It's going to need to be used by the upgrader of machine instances as well, that's why.

Contributes to issue CURA-844.
This commit is contained in:
Ghostkeeper 2016-08-09 13:27:48 +02:00
parent 7481f0802e
commit 36f84017cf
No known key found for this signature in database
GPG key ID: 701948C5954A7385
2 changed files with 19 additions and 12 deletions

View file

@ -7,17 +7,6 @@ import io #To write config files to strings as if they were files.
import UM.VersionUpgrade import UM.VersionUpgrade
## Which machines have material-specific profiles in the new version?
#
# These are the 2.1 machine identities with "has_machine_materials": true in
# their definitions in Cura 2.2. So these are the machines for which profiles
# need to split into multiple profiles, one for each material.
#
# This should contain the definition as they are stated in the profiles. The
# inheritance structure cannot be found at this stage, since the definitions
# may have changed in later versions than 2.2.
_machines_with_machine_quality = {"ultimaker2plus", "ultimaker2_extended_plus"}
## The materials in Cura 2.2. ## The materials in Cura 2.2.
# #
# This is required to know how to split old profiles if the old machine didn't # This is required to know how to split old profiles if the old machine didn't
@ -153,7 +142,7 @@ class Profile:
config.set("metadata", "material", self._material_name) config.set("metadata", "material", self._material_name)
filenames.append(self._filename) filenames.append(self._filename)
configs.append(config) configs.append(config)
elif self._type != "material" and self._machine_type_id in _machines_with_machine_quality: elif self._type != "material" and self._machine_type_id in VersionUpgrade21to22.machines_with_machine_quality():
#Split this profile into multiple profiles, one for each material. #Split this profile into multiple profiles, one for each material.
for material_id in _new_materials: for material_id in _new_materials:
filenames.append("{profile}_{material}".format(profile = self._filename, material = material_id)) filenames.append("{profile}_{material}".format(profile = self._filename, material = material_id))

View file

@ -9,6 +9,17 @@ from . import MachineInstance # To upgrade machine instances.
from . import Preferences #To upgrade preferences. from . import Preferences #To upgrade preferences.
from . import Profile # To upgrade profiles. from . import Profile # To upgrade profiles.
## Which machines have material-specific profiles in the new version?
#
# These are the 2.1 machine identities with "has_machine_materials": true in
# their definitions in Cura 2.2. So these are the machines for which profiles
# need to split into multiple profiles, one for each material.
#
# This should contain the definition as they are stated in the profiles. The
# inheritance structure cannot be found at this stage, since the definitions
# may have changed in later versions than 2.2.
_machines_with_machine_quality = {"ultimaker2plus", "ultimaker2_extended_plus"}
## How to translate printer names from the old version to the new. ## How to translate printer names from the old version to the new.
_printer_translations = { _printer_translations = {
"ultimaker2plus": "ultimaker2_plus" "ultimaker2plus": "ultimaker2_plus"
@ -77,6 +88,13 @@ class VersionUpgrade21to22(VersionUpgrade):
parser.read_string(serialised) parser.read_string(serialised)
return int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. return int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
## Gets a set of the machines which now have per-material quality profiles.
#
# \return A set of machine identifiers.
@staticmethod
def machines_with_machine_quality(self):
return _machines_with_machine_quality
## Converts machine instances from format version 1 to version 2. ## Converts machine instances from format version 1 to version 2.
# #
# \param serialised The serialised machine instance in version 1. # \param serialised The serialised machine instance in version 1.