Commit 86e8d3d0 authored by Łukasz Nowak's avatar Łukasz Nowak

Optimise XML tree analysis (thanks to Nicolas Delaby)

parent 0dc0361e
...@@ -51,13 +51,12 @@ class SoftwareInstance(Item): ...@@ -51,13 +51,12 @@ class SoftwareInstance(Item):
xml = self.getSlaXml() xml = self.getSlaXml()
if xml is not None and xml != '': if xml is not None and xml != '':
tree = etree.fromstring(xml.encode('utf-8')) tree = etree.fromstring(xml.encode('utf-8'))
for element in tree.iter(tag=etree.Element): for element in tree.findall('parameter'):
if element.tag == 'parameter': key = element.get('id')
key = element.get('id') value = result_dict.get(key, None)
value = result_dict.get(key, None) if value is not None:
if value is not None: value = value + ' ' + element.text
value = value + ' ' + element.text else:
else: value = element.text
value = element.text result_dict[key] = value
result_dict[key] = value
return result_dict return result_dict
241 242
\ No newline at end of file \ No newline at end of file
...@@ -346,15 +346,14 @@ class SlapTool(BaseTool): ...@@ -346,15 +346,14 @@ class SlapTool(BaseTool):
result_dict = {} result_dict = {}
if xml is not None and xml != '': if xml is not None and xml != '':
tree = etree.fromstring(xml.encode('utf-8')) tree = etree.fromstring(xml.encode('utf-8'))
for element in tree.iter(tag=etree.Element): for element in tree.findall('parameter'):
if element.tag == 'parameter': key = element.get('id')
key = element.get('id') value = result_dict.get(key, None)
value = result_dict.get(key, None) if value is not None:
if value is not None: value = value + ' ' + element.text
value = value + ' ' + element.text else:
else: value = element.text
value = element.text result_dict[key] = value
result_dict[key] = value
return result_dict return result_dict
def _getModificationStatusForSlave(self, computer_partition_document): def _getModificationStatusForSlave(self, computer_partition_document):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment