2 from xml.etree
import ElementTree
4 def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family):
5 cmask =
map(int, cmask)
6 invmask =
map(int, invmask)
7 sampling_period =
map(int, sampling_period)
8 startatevent = int(startatevent)
10 from Configurables
import ApplicationMgr, AuditorSvc, PerfMonAuditor
12 app.AuditAlgorithms = 1
15 pfaud.EVENT0 = counter[0]
16 pfaud.SP0 = sampling_period[0]
17 pfaud.INV0 = int(invmask[0])
18 pfaud.CMASK0 = int(cmask[0])
19 pfaud.EVENT1 = counter[1]
20 pfaud.SP1 = sampling_period[1]
21 pfaud.INV1 = int(invmask[1])
22 pfaud.CMASK1 = int(cmask[1])
23 pfaud.EVENT2 = counter[2]
24 pfaud.SP2 = sampling_period[2]
25 pfaud.INV2 = int(invmask[2])
26 pfaud.CMASK2 = int(cmask[2])
27 pfaud.EVENT3 = counter[3]
28 pfaud.SP3 = sampling_period[3]
29 pfaud.INV3 = int(invmask[3])
30 pfaud.CMASK3 = int(cmask[3])
34 pfaud.PREFIX =
"%s_%s" % (storeresultsat,
"S" if sampling_period[0] > 0
else "C")
35 pfaud.SAMPLE = int(sampling_period[0] > 0)
36 pfaud.START_AT_EVENT = startatevent
44 Adds object like functionality to the standard dictionary. 50 dict.__init__(self, initdict)
53 return self.__getitem__(item)
56 self.__setitem__(item, value)
59 if self.has_key(
'_text'):
60 return self.__getitem__(
'_text')
67 Static method to wrap a dictionary recursively as an XmlDictObject 70 if isinstance(x, dict):
71 return XmlDictObject((k, XmlDictObject.Wrap(v))
for (k, v)
in x.iteritems())
72 elif isinstance(x, list):
73 return [XmlDictObject.Wrap(v)
for v
in x]
79 if isinstance(x, dict):
80 return dict((k, XmlDictObject._UnWrap(v))
for (k, v)
in x.iteritems())
81 elif isinstance(x, list):
82 return [XmlDictObject._UnWrap(v)
for v
in x]
88 Recursively converts an XmlDictObject to a standard dictionary and returns the result. 91 return XmlDictObject._UnWrap(self)
94 assert type(dictitem)
is not type([])
96 if isinstance(dictitem, dict):
97 for (tag, child)
in dictitem.iteritems():
98 if str(tag) ==
'_text':
99 parent.text = str(child)
102 for listchild
in child:
103 elem = ElementTree.Element(tag)
107 elem = ElementTree.Element(tag)
111 parent.text = str(dictitem)
115 Converts a dictionary to an XML ElementTree Element 118 roottag = xmldict.keys()[0]
119 root = ElementTree.Element(roottag)
124 nodedict = dictclass()
126 if len(node.items()) > 0:
128 nodedict.update(dict(node.items()))
133 if nodedict.has_key(child.tag):
135 if type(nodedict[child.tag])
is type([]):
137 nodedict[child.tag].append(newitem)
140 nodedict[child.tag] = [nodedict[child.tag], newitem]
143 nodedict[child.tag] = newitem
145 if node.text
is None:
148 text = node.text.strip()
150 if len(nodedict) > 0:
153 nodedict[
'_text'] = text
162 Converts an XML file or ElementTree Element to a dictionary 167 root = ElementTree.parse(root).getroot()
168 elif not isinstance(root, ElementTree.Element):
169 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)