All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiProfiling.GenerateGaudiOpts Namespace Reference

Classes

class  XmlDictObject
 

Functions

def generateOptions
 
def _ConvertDictToXmlRecurse
 
def ConvertDictToXml
 
def _ConvertXmlToDictRecurse
 
def ConvertXmlToDict
 

Function Documentation

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

Definition at line 93 of file GenerateGaudiOpts.py.

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

Definition at line 123 of file GenerateGaudiOpts.py.

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

Definition at line 113 of file GenerateGaudiOpts.py.

114 def ConvertDictToXml(xmldict):
115  """
116  Converts a dictionary to an XML ElementTree Element
117  """
118 
119  roottag = xmldict.keys()[0]
120  root = ElementTree.Element(roottag)
121  _ConvertDictToXmlRecurse(root, xmldict[roottag])
122  return root
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.

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

Definition at line 4 of file GenerateGaudiOpts.py.

4 
5 def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family):
6  cmask = map(int, cmask)
7  invmask = map(int, invmask)
8  sampling_period = map(int, sampling_period)
9  startatevent = int(startatevent)
10 
11  from Configurables import ApplicationMgr, AuditorSvc, PerfMonAuditor
12  app = ApplicationMgr()
13  app.AuditAlgorithms = 1
14  pfaud = PerfMonAuditor()
15  try:
16  pfaud.EVENT0 = counter[0]
17  pfaud.SP0 = sampling_period[0]
18  pfaud.INV0 = int(invmask[0])
19  pfaud.CMASK0 = int(cmask[0])
20  pfaud.EVENT1 = counter[1]
21  pfaud.SP1 = sampling_period[1]
22  pfaud.INV1 = int(invmask[1])
23  pfaud.CMASK1 = int(cmask[1])
24  pfaud.EVENT2 = counter[2]
25  pfaud.SP2 = sampling_period[2]
26  pfaud.INV2 = int(invmask[2])
27  pfaud.CMASK2 = int(cmask[2])
28  pfaud.EVENT3 = counter[3]
29  pfaud.SP3 = sampling_period[3]
30  pfaud.INV3 = int(invmask[3])
31  pfaud.CMASK3 = int(cmask[3])
32  except IndexError:
33  pass
34  pfaud.FAMILY = family
35  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
36  pfaud.SAMPLE = int(sampling_period[0] > 0)
37  pfaud.START_AT_EVENT = startatevent
38  #pfaud.LEVEL = 5
39  AuditorSvc().Auditors.append(pfaud)
40  print pfaud
41 
Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.
struct GAUDI_API map
Parametrisation class for map-like implementation.
The Application Manager class.