Load setting_version from XML material profile

The setting_version is translated from the version number. The setting_version number currently happens to be the same as the version number of XML but that won't always be the case so we introduce a translation-step as well.

Contributes to issue CURA-3427.
This commit is contained in:
Ghostkeeper 2017-05-12 14:04:56 +02:00
parent 38f081539a
commit c8295434f3
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -21,6 +21,17 @@ class XmlMaterialProfile(InstanceContainer):
super().__init__(container_id, *args, **kwargs) super().__init__(container_id, *args, **kwargs)
self._inherited_files = [] self._inherited_files = []
## Translates the version number in the XML files to the setting_version
# metadata entry.
#
# Since the two may increment independently we need a way to say which
# versions of the XML specification are compatible with our setting data
# version numbers.
def xmlVersionToSettingVersion(self, xml_version):
if xml_version == 1: #Only one known version and it happens to be the same as our current setting_version.
return 1
return 0
def getInheritedFiles(self): def getInheritedFiles(self):
return self._inherited_files return self._inherited_files
@ -403,6 +414,7 @@ class XmlMaterialProfile(InstanceContainer):
meta_data["type"] = "material" meta_data["type"] = "material"
meta_data["base_file"] = self.id meta_data["base_file"] = self.id
meta_data["status"] = "unknown" # TODO: Add material verfication meta_data["status"] = "unknown" # TODO: Add material verfication
meta_data["setting_version"] = self.getVersionFromSerialized(serialized)
inherits = data.find("./um:inherits", self.__namespaces) inherits = data.find("./um:inherits", self.__namespaces)
if inherits is not None: if inherits is not None: