Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v30r3 (a5ef0a68)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 99 of file GenerateGaudiOpts.py.

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

Definition at line 131 of file GenerateGaudiOpts.py.

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

Definition at line 120 of file GenerateGaudiOpts.py.

120 def ConvertDictToXml(xmldict):
121  """
122  Converts a dictionary to an XML ElementTree Element
123  """
124 
125  roottag = xmldict.keys()[0]
126  root = ElementTree.Element(roottag)
127  _ConvertDictToXmlRecurse(root, xmldict[roottag])
128  return root
129 
130 
def _ConvertDictToXmlRecurse(parent, dictitem)
def GaudiProfiling.GenerateGaudiOpts.ConvertXmlToDict (   root,
  dictclass = XmlDictObject 
)
Converts an XML file or ElementTree Element to a dictionary

Definition at line 169 of file GenerateGaudiOpts.py.

169 def ConvertXmlToDict(root, dictclass=XmlDictObject):
170  """
171  Converts an XML file or ElementTree Element to a dictionary
172  """
173 
174  # If a string is passed in, try to open it as a file
175  if type(root) == type(''):
176  root = ElementTree.parse(root).getroot()
177  elif not isinstance(root, ElementTree.Element):
178  raise TypeError, 'Expected ElementTree.Element or file path string'
179 
180  return dictclass({root.tag: _ConvertXmlToDictRecurse(root, dictclass)})
181 
def _ConvertXmlToDictRecurse(node, dictclass)
def ConvertXmlToDict(root, dictclass=XmlDictObject)
def GaudiProfiling.GenerateGaudiOpts.generateOptions (   counter,
  cmask,
  invmask,
  sampling_period,
  startatevent,
  storeresultsat,
  family 
)

Definition at line 7 of file GenerateGaudiOpts.py.

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)
12 
13  from Configurables import ApplicationMgr, AuditorSvc, PerfMonAuditor
14  app = ApplicationMgr()
15  app.AuditAlgorithms = 1
16  pfaud = PerfMonAuditor()
17  try:
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])
34  except IndexError:
35  pass
36  pfaud.FAMILY = family
37  # for <2.5 Python use: test and true_value or false_value
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
42  #pfaud.LEVEL = 5
43  AuditorSvc().Auditors.append(pfaud)
44  print pfaud
45 
46 
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.