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

Add methods to fetch XMLs as dicts.

parent ddd08eef
......@@ -50,14 +50,13 @@ class SoftwareInstance(Item):
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation,
'getSlaXmlAsDict')
def getSlaXmlAsDict(self):
"""Returns SLA XML as python dictionary"""
def _getXmlAsDict(self, xml):
result_dict = {}
xml = self.getSlaXml()
if xml is not None and xml != '':
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)
......@@ -68,6 +67,24 @@ class SoftwareInstance(Item):
result_dict[key] = value
return result_dict
security.declareProtected(Permissions.AccessContentsInformation,
'getSlaXmlAsDict')
def getSlaXmlAsDict(self):
"""Returns SLA XML as python dictionary"""
return self._getXmlAsDict(self.getSlaXml())
security.declareProtected(Permissions.AccessContentsInformation,
'getInstanceXmlAsDict')
def getInstanceXmlAsDict(self):
"""Returns Instance XML as python dictionary"""
return self._getXmlAsDict(self.getTextContent())
security.declareProtected(Permissions.AccessContentsInformation,
'getConnectionXmlAsDict')
def getConnectionXmlAsDict(self):
"""Returns Connection XML as python dictionary"""
return self._getXmlAsDict(self.getConnectionXml())
security.declareProtected(Permissions.AccessContentsInformation,
'checkNotCyclic')
def checkNotCyclic(self, graph):
......
401
\ No newline at end of file
402
\ 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