GaudiProfiling.GenerateGaudiOpts Namespace Reference

Classes

class  XmlDictObject
 

Functions

def generateOptions (counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family)
 
def _ConvertDictToXmlRecurse (parent, dictitem)
 
def ConvertDictToXml (xmldict)
 
def _ConvertXmlToDictRecurse (node, dictclass)
 
def ConvertXmlToDict (root, dictclass=XmlDictObject)
 

Function Documentation

def GaudiProfiling.GenerateGaudiOpts._ConvertDictToXmlRecurse (   parent,
  dictitem 
)
private

Definition at line 93 of file GenerateGaudiOpts.py.

93 def _ConvertDictToXmlRecurse(parent, dictitem):
94  assert type(dictitem) is not type([])
95 
96  if isinstance(dictitem, dict):
97  for (tag, child) in dictitem.iteritems():
98  if str(tag) == '_text':
99  parent.text = str(child)
100  elif type(child) is type([]):
101  # iterate through the array and convert
102  for listchild in child:
103  elem = ElementTree.Element(tag)
104  parent.append(elem)
105  _ConvertDictToXmlRecurse(elem, listchild)
106  else:
107  elem = ElementTree.Element(tag)
108  parent.append(elem)
109  _ConvertDictToXmlRecurse(elem, child)
110  else:
111  parent.text = str(dictitem)
112 
def _ConvertDictToXmlRecurse(parent, dictitem)
def GaudiProfiling.GenerateGaudiOpts._ConvertXmlToDictRecurse (   node,
  dictclass 
)
private

Definition at line 123 of file GenerateGaudiOpts.py.

123 def _ConvertXmlToDictRecurse(node, dictclass):
124  nodedict = dictclass()
125 
126  if len(node.items()) > 0:
127  # if we have attributes, set them
128  nodedict.update(dict(node.items()))
129 
130  for child in node:
131  # recursively add the element's children
132  newitem = _ConvertXmlToDictRecurse(child, dictclass)
133  if nodedict.has_key(child.tag):
134  # found duplicate tag, force a list
135  if type(nodedict[child.tag]) is type([]):
136  # append to existing list
137  nodedict[child.tag].append(newitem)
138  else:
139  # convert to list
140  nodedict[child.tag] = [nodedict[child.tag], newitem]
141  else:
142  # only one, directly set the dictionary
143  nodedict[child.tag] = newitem
144 
145  if node.text is None:
146  text = ''
147  else:
148  text = node.text.strip()
149 
150  if len(nodedict) > 0:
151  # if we have a dictionary add the text as a dictionary value (if there is any)
152  if len(text) > 0:
153  nodedict['_text'] = text
154  else:
155  # if we don't have child nodes or attributes, just set the text
156  nodedict = text
157 
158  return nodedict
159 
def _ConvertXmlToDictRecurse(node, dictclass)
def GaudiProfiling.GenerateGaudiOpts.ConvertDictToXml (   xmldict)
Converts a dictionary to an XML ElementTree Element 

Definition at line 113 of file GenerateGaudiOpts.py.

113 def ConvertDictToXml(xmldict):
114  """
115  Converts a dictionary to an XML ElementTree Element
116  """
117 
118  roottag = xmldict.keys()[0]
119  root = ElementTree.Element(roottag)
120  _ConvertDictToXmlRecurse(root, xmldict[roottag])
121  return root
122 
def _ConvertDictToXmlRecurse(parent, dictitem)
def GaudiProfiling.GenerateGaudiOpts.ConvertXmlToDict (   root,
  dictclass = XmlDictObject 
)
Converts an XML file or ElementTree Element to a dictionary

Definition at line 160 of file GenerateGaudiOpts.py.

160 def ConvertXmlToDict(root, dictclass=XmlDictObject):
161  """
162  Converts an XML file or ElementTree Element to a dictionary
163  """
164 
165  # If a string is passed in, try to open it as a file
166  if type(root) == type(''):
167  root = ElementTree.parse(root).getroot()
168  elif not isinstance(root, ElementTree.Element):
169  raise TypeError, 'Expected ElementTree.Element or file path string'
170 
171  return dictclass({root.tag: _ConvertXmlToDictRecurse(root, dictclass)})
172 
def _ConvertXmlToDictRecurse(node, dictclass)
def ConvertXmlToDict(root, dictclass=XmlDictObject)
def GaudiProfiling.GenerateGaudiOpts.generateOptions (   counter,
  cmask,
  invmask,
  sampling_period,
  startatevent,
  storeresultsat,
  family 
)

Definition at line 4 of file GenerateGaudiOpts.py.

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)
9 
10  from Configurables import ApplicationMgr, AuditorSvc, PerfMonAuditor
11  app = ApplicationMgr()
12  app.AuditAlgorithms = 1
13  pfaud = PerfMonAuditor()
14  try:
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])
31  except IndexError:
32  pass
33  pfaud.FAMILY = family
34  pfaud.PREFIX = "%s_%s" % (storeresultsat, "S" if sampling_period[0] > 0 else "C") # for <2.5 Python use: test and true_value or false_value
35  pfaud.SAMPLE = int(sampling_period[0] > 0)
36  pfaud.START_AT_EVENT = startatevent
37  #pfaud.LEVEL = 5
38  AuditorSvc().Auditors.append(pfaud)
39  print pfaud
40 
41 
def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family)
Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.
struct GAUDI_API map
Parametrisation class for map-like implementation.
The Application Manager class.