Commit 4c838a5f authored by Łukasz Nowak's avatar Łukasz Nowak

Add methods to fetch XMLs as dicts.

parent ddd08eef
...@@ -50,23 +50,40 @@ class SoftwareInstance(Item): ...@@ -50,23 +50,40 @@ class SoftwareInstance(Item):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getXmlAsDict(self, xml):
result_dict = {}
if xml is None or xml == '':
return result_dict
tree = etree.fromstring(xml.encode('utf-8'))
for element in tree.findall('parameter'):
key = element.get('id')
value = result_dict.get(key, None)
if value is not None:
value = value + ' ' + element.text
else:
value = element.text
result_dict[key] = value
return result_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getSlaXmlAsDict') 'getSlaXmlAsDict')
def getSlaXmlAsDict(self): def getSlaXmlAsDict(self):
"""Returns SLA XML as python dictionary""" """Returns SLA XML as python dictionary"""
result_dict = {} return self._getXmlAsDict(self.getSlaXml())
xml = self.getSlaXml()
if xml is not None and xml != '': security.declareProtected(Permissions.AccessContentsInformation,
tree = etree.fromstring(xml.encode('utf-8')) 'getInstanceXmlAsDict')
for element in tree.findall('parameter'): def getInstanceXmlAsDict(self):
key = element.get('id') """Returns Instance XML as python dictionary"""
value = result_dict.get(key, None) return self._getXmlAsDict(self.getTextContent())
if value is not None:
value = value + ' ' + element.text security.declareProtected(Permissions.AccessContentsInformation,
else: 'getConnectionXmlAsDict')
value = element.text def getConnectionXmlAsDict(self):
result_dict[key] = value """Returns Connection XML as python dictionary"""
return result_dict return self._getXmlAsDict(self.getConnectionXml())
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'checkNotCyclic') 'checkNotCyclic')
......
401 402
\ No newline at end of file \ No newline at end of file
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