mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
Convert some functions to static
This commit is contained in:
parent
a6c27787b9
commit
608ca3e92a
1 changed files with 7 additions and 6 deletions
|
@ -409,7 +409,8 @@ class XmlMaterialProfile(InstanceContainer):
|
||||||
self._combineElement(self._expandMachinesXML(result), self._expandMachinesXML(second))
|
self._combineElement(self._expandMachinesXML(result), self._expandMachinesXML(second))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _createKey(self, element):
|
@staticmethod
|
||||||
|
def _createKey(element):
|
||||||
key = element.tag.split("}")[-1]
|
key = element.tag.split("}")[-1]
|
||||||
if "key" in element.attrib:
|
if "key" in element.attrib:
|
||||||
key += " key:" + element.attrib["key"]
|
key += " key:" + element.attrib["key"]
|
||||||
|
@ -425,15 +426,15 @@ class XmlMaterialProfile(InstanceContainer):
|
||||||
|
|
||||||
# Recursively merges XML elements. Updates either the text or children if another element is found in first.
|
# Recursively merges XML elements. Updates either the text or children if another element is found in first.
|
||||||
# If it does not exist, copies it from second.
|
# If it does not exist, copies it from second.
|
||||||
def _combineElement(self, first, second):
|
@staticmethod
|
||||||
|
def _combineElement(first, second):
|
||||||
# Create a mapping from tag name to element.
|
# Create a mapping from tag name to element.
|
||||||
|
|
||||||
mapping = {}
|
mapping = {}
|
||||||
for element in first:
|
for element in first:
|
||||||
key = self._createKey(element)
|
key = XmlMaterialProfile._createKey(element)
|
||||||
mapping[key] = element
|
mapping[key] = element
|
||||||
for element in second:
|
for element in second:
|
||||||
key = self._createKey(element)
|
key = XmlMaterialProfile._createKey(element)
|
||||||
if len(element): # Check if element has children.
|
if len(element): # Check if element has children.
|
||||||
try:
|
try:
|
||||||
if "setting" in element.tag and not "settings" in element.tag:
|
if "setting" in element.tag and not "settings" in element.tag:
|
||||||
|
@ -443,7 +444,7 @@ class XmlMaterialProfile(InstanceContainer):
|
||||||
for child in element:
|
for child in element:
|
||||||
mapping[key].append(child)
|
mapping[key].append(child)
|
||||||
else:
|
else:
|
||||||
self._combineElement(mapping[key], element) # Multiple elements, handle those.
|
XmlMaterialProfile._combineElement(mapping[key], element) # Multiple elements, handle those.
|
||||||
except KeyError:
|
except KeyError:
|
||||||
mapping[key] = element
|
mapping[key] = element
|
||||||
first.append(element)
|
first.append(element)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue