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): ...@@ -50,14 +50,13 @@ class SoftwareInstance(Item):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation, def _getXmlAsDict(self, xml):
'getSlaXmlAsDict')
def getSlaXmlAsDict(self):
"""Returns SLA XML as python dictionary"""
result_dict = {} result_dict = {}
xml = self.getSlaXml() if xml is None or xml == '':
if xml is not None and xml != '': return result_dict
tree = etree.fromstring(xml.encode('utf-8')) tree = etree.fromstring(xml.encode('utf-8'))
for element in tree.findall('parameter'): for element in tree.findall('parameter'):
key = element.get('id') key = element.get('id')
value = result_dict.get(key, None) value = result_dict.get(key, None)
...@@ -68,6 +67,24 @@ class SoftwareInstance(Item): ...@@ -68,6 +67,24 @@ class SoftwareInstance(Item):
result_dict[key] = value result_dict[key] = value
return result_dict 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, security.declareProtected(Permissions.AccessContentsInformation,
'checkNotCyclic') 'checkNotCyclic')
def checkNotCyclic(self, graph): def checkNotCyclic(self, graph):
......
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