4 from xml.etree
import ElementTree
7 def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family):
8 cmask =
map(int, cmask)
9 invmask =
map(int, invmask)
10 sampling_period =
map(int, sampling_period)
11 startatevent = int(startatevent)
13 from Configurables
import ApplicationMgr, AuditorSvc, PerfMonAuditor
15 app.AuditAlgorithms = 1
18 pfaud.EVENT0 = counter[0]
19 pfaud.SP0 = sampling_period[0]
20 pfaud.INV0 = int(invmask[0])
21 pfaud.CMASK0 = int(cmask[0])
22 pfaud.EVENT1 = counter[1]
23 pfaud.SP1 = sampling_period[1]
24 pfaud.INV1 = int(invmask[1])
25 pfaud.CMASK1 = int(cmask[1])
26 pfaud.EVENT2 = counter[2]
27 pfaud.SP2 = sampling_period[2]
28 pfaud.INV2 = int(invmask[2])
29 pfaud.CMASK2 = int(cmask[2])
30 pfaud.EVENT3 = counter[3]
31 pfaud.SP3 = sampling_period[3]
32 pfaud.INV3 = int(invmask[3])
33 pfaud.CMASK3 = int(cmask[3])
38 pfaud.PREFIX =
"%s_%s" % (
39 storeresultsat,
"S" if sampling_period[0] > 0
else "C")
40 pfaud.SAMPLE = int(sampling_period[0] > 0)
41 pfaud.START_AT_EVENT = startatevent
49 Adds object like functionality to the standard dictionary. 55 dict.__init__(self, initdict)
58 return self.__getitem__(item)
61 self.__setitem__(item, value)
64 if self.has_key(
'_text'):
65 return self.__getitem__(
'_text')
72 Static method to wrap a dictionary recursively as an XmlDictObject 75 if isinstance(x, dict):
76 return XmlDictObject((k, XmlDictObject.Wrap(v))
for (k, v)
in x.iteritems())
77 elif isinstance(x, list):
78 return [XmlDictObject.Wrap(v)
for v
in x]
84 if isinstance(x, dict):
85 return dict((k, XmlDictObject._UnWrap(v))
for (k, v)
in x.iteritems())
86 elif isinstance(x, list):
87 return [XmlDictObject._UnWrap(v)
for v
in x]
93 Recursively converts an XmlDictObject to a standard dictionary and returns the result. 96 return XmlDictObject._UnWrap(self)
100 assert type(dictitem)
is not type([])
102 if isinstance(dictitem, dict):
103 for (tag, child)
in dictitem.iteritems():
104 if str(tag) ==
'_text':
105 parent.text = str(child)
108 for listchild
in child:
109 elem = ElementTree.Element(tag)
113 elem = ElementTree.Element(tag)
117 parent.text = str(dictitem)
122 Converts a dictionary to an XML ElementTree Element 125 roottag = xmldict.keys()[0]
126 root = ElementTree.Element(roottag)
132 nodedict = dictclass()
134 if len(node.items()) > 0:
136 nodedict.update(dict(node.items()))
141 if nodedict.has_key(child.tag):
143 if type(nodedict[child.tag])
is type([]):
145 nodedict[child.tag].append(newitem)
148 nodedict[child.tag] = [nodedict[child.tag], newitem]
151 nodedict[child.tag] = newitem
153 if node.text
is None:
156 text = node.text.strip()
158 if len(nodedict) > 0:
161 nodedict[
'_text'] = text
171 Converts an XML file or ElementTree Element to a dictionary 176 root = ElementTree.parse(root).getroot()
177 elif not isinstance(root, ElementTree.Element):
178 raise TypeError,
'Expected ElementTree.Element or file path string' def __setattr__(self, item, value)
def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family)
def _ConvertXmlToDictRecurse(node, dictclass)
Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.
def __getattr__(self, item)
def ConvertDictToXml(xmldict)
struct GAUDI_API map
Parametrisation class for map-like implementation.
def _ConvertDictToXmlRecurse(parent, dictitem)
def ConvertXmlToDict(root, dictclass=XmlDictObject)
The Application Manager class.
def __init__(self, initdict=None)