From c8295434f36a406b5328c0202ee84691339aa49d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 12 May 2017 14:04:56 +0200 Subject: [PATCH] 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. --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 0da3afa125..2878369cdd 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -21,6 +21,17 @@ class XmlMaterialProfile(InstanceContainer): super().__init__(container_id, *args, **kwargs) 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): return self._inherited_files @@ -403,6 +414,7 @@ class XmlMaterialProfile(InstanceContainer): meta_data["type"] = "material" meta_data["base_file"] = self.id meta_data["status"] = "unknown" # TODO: Add material verfication + meta_data["setting_version"] = self.getVersionFromSerialized(serialized) inherits = data.find("./um:inherits", self.__namespaces) if inherits is not None: