CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | Private Attributes
XML2Python.TreeBuilder Class Reference
Inheritance diagram for XML2Python.TreeBuilder:

Public Member Functions

def __init__
 
def __init__
 
def characters
 
def characters
 
def endElement
 
def endElement
 
def root
 
def root
 
def startElement
 
def startElement
 
def topLevel
 
def topLevel
 

Public Attributes

 current
 

Static Public Attributes

tuple non_id_char = re.compile('[^_0-9a-zA-Z]')
 

Static Private Member Functions

def _name_mangle
 
def _name_mangle
 

Private Attributes

 _ncDict
 
 _root
 
 _stack
 
 _text_parts
 

Detailed Description

Definition at line 159 of file XML2Python.py.

Constructor & Destructor Documentation

def XML2Python.TreeBuilder.__init__ (   self,
  kwargs 
)

Definition at line 163 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__().

164  def __init__ (self, **kwargs):
165  self._stack = []
166  self._text_parts = []
167  self._ncDict = kwargs.get ('nameChangeDict', {})
168  self._root = DataNode (nameChangeDict = self._ncDict)
169  self.current = self._root
def XML2Python.TreeBuilder.__init__ (   self,
  kwargs 
)

Definition at line 69 of file XML2Python.py.

References XML2Python.TreeBuilder.__init__(), XML2Python.DataNode._ncDict, XML2Python.TreeBuilder._ncDict, HcalTriggerKey._root, data_sources.tree._root, HcalChannelDataXml._root, XML2Python.TreeBuilder._root, XML2Python.TreeBuilder._stack, XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder.current, and svgfig.Curve.Samples.current.

69 
70  def __init__ (self, **kwargs):
71  self._stack = []
72  self._text_parts = []
73  self._ncDict = kwargs.get ('nameChangeDict', {})
74  self._root = DataNode (nameChangeDict = self._ncDict)
75  self.current = self._root

Member Function Documentation

def XML2Python.TreeBuilder._name_mangle (   name)
staticprivate

Definition at line 108 of file XML2Python.py.

References XML2Python.TreeBuilder._name_mangle().

109  def _name_mangle (name):
110  return TreeBuilder.non_id_char.sub('_', name)
111 
def XML2Python.TreeBuilder._name_mangle (   name)
staticprivate

Definition at line 202 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder._name_mangle().

203  def _name_mangle (name):
204  return TreeBuilder.non_id_char.sub('_', name)
205 
def XML2Python.TreeBuilder.characters (   self,
  content 
)

Definition at line 96 of file XML2Python.py.

References XML2Python.TreeBuilder.characters().

96 
97  def characters (self, content):
98  self._text_parts.append(content)
def XML2Python.TreeBuilder.characters (   self,
  content 
)

Definition at line 190 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.characters().

191  def characters (self, content):
192  self._text_parts.append(content)
def XML2Python.TreeBuilder.endElement (   self,
  name 
)

Definition at line 84 of file XML2Python.py.

References XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder.current, svgfig.Curve.Samples.current, and XML2Python.TreeBuilder.endElement().

84 
85  def endElement (self, name):
86  text = ''.join (self._text_parts).strip()
87  if text:
88  self.current._data = text
89  if self.current.attributes():
90  obj = self.current
91  else:
92  # a text only node is simply represented by the string
93  obj = text or ''
94  self.current, self._text_parts = self._stack.pop()
95  self.current._add_xml_attr (TreeBuilder._name_mangle(name), obj)
def XML2Python.TreeBuilder.endElement (   self,
  name 
)

Definition at line 178 of file XML2Python.py.

References XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder.current, and svgfig.Curve.Samples.current.

Referenced by XML2Python.TreeBuilder.endElement().

179  def endElement (self, name):
180  text = ''.join (self._text_parts).strip()
181  if text:
182  self.current._data = text
183  if self.current.attributes():
184  obj = self.current
185  else:
186  # a text only node is simply represented by the string
187  obj = text or ''
188  self.current, self._text_parts = self._stack.pop()
189  self.current._add_xml_attr (TreeBuilder._name_mangle(name), obj)
def XML2Python.TreeBuilder.root (   self)

Definition at line 99 of file XML2Python.py.

References HcalTriggerKey._root, data_sources.tree._root, HcalChannelDataXml._root, XML2Python.TreeBuilder._root, and XML2Python.TreeBuilder.root().

99 
100  def root (self):
101  return self._root
def XML2Python.TreeBuilder.root (   self)

Definition at line 193 of file XML2Python.py.

References HcalTriggerKey._root, data_sources.tree._root, HcalChannelDataXml._root, and XML2Python.TreeBuilder._root.

Referenced by XML2Python.TreeBuilder.root().

194  def root (self):
195  return self._root
def XML2Python.TreeBuilder.startElement (   self,
  name,
  attrs 
)

Definition at line 76 of file XML2Python.py.

References XML2Python.DataNode._ncDict, XML2Python.TreeBuilder._ncDict, XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder.current, svgfig.Curve.Samples.current, and XML2Python.TreeBuilder.startElement().

76 
77  def startElement (self, name, attrs):
78  self._stack.append( (self.current, self._text_parts))
79  self.current = DataNode (nameChangeDict = self._ncDict)
80  self._text_parts = []
81  # xml attributes --> python attributes
82  for k, v in attrs.items():
83  self.current._add_xml_attr (TreeBuilder._name_mangle(k), v)
def XML2Python.TreeBuilder.startElement (   self,
  name,
  attrs 
)

Definition at line 170 of file XML2Python.py.

References XML2Python.DataNode._ncDict, XML2Python.TreeBuilder._ncDict, XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder.current, and svgfig.Curve.Samples.current.

Referenced by XML2Python.TreeBuilder.startElement().

171  def startElement (self, name, attrs):
172  self._stack.append( (self.current, self._text_parts))
173  self.current = DataNode (nameChangeDict = self._ncDict)
174  self._text_parts = []
175  # xml attributes --> python attributes
176  for k, v in attrs.items():
177  self.current._add_xml_attr (TreeBuilder._name_mangle(k), v)
def XML2Python.TreeBuilder.topLevel (   self)
Returns top level object

Definition at line 102 of file XML2Python.py.

References XML2Python.TreeBuilder.topLevel(), and makeHLTPrescaleTable.values.

103  def topLevel (self):
104  '''Returns top level object'''
105  return self._root.attributes().values()[0]
106 
def XML2Python.TreeBuilder.topLevel (   self)
Returns top level object

Definition at line 196 of file XML2Python.py.

References makeHLTPrescaleTable.values.

Referenced by XML2Python.TreeBuilder.topLevel().

197  def topLevel (self):
198  '''Returns top level object'''
199  return self._root.attributes().values()[0]
200 

Member Data Documentation

XML2Python.TreeBuilder._ncDict
private

Definition at line 166 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__(), python.XML2Python.TreeBuilder.startElement(), and XML2Python.TreeBuilder.startElement().

XML2Python.TreeBuilder._root
private

Definition at line 167 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__(), python.XML2Python.TreeBuilder.root(), and XML2Python.TreeBuilder.root().

XML2Python.TreeBuilder._stack
private

Definition at line 164 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__().

XML2Python.TreeBuilder._text_parts
private

Definition at line 165 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__(), python.XML2Python.TreeBuilder.endElement(), XML2Python.TreeBuilder.endElement(), python.XML2Python.TreeBuilder.startElement(), and XML2Python.TreeBuilder.startElement().

XML2Python.TreeBuilder.current

Definition at line 168 of file XML2Python.py.

Referenced by XML2Python.TreeBuilder.__init__(), python.XML2Python.TreeBuilder.endElement(), XML2Python.TreeBuilder.endElement(), python.XML2Python.TreeBuilder.startElement(), and XML2Python.TreeBuilder.startElement().

tuple XML2Python.TreeBuilder.non_id_char = re.compile('[^_0-9a-zA-Z]')
static

Definition at line 161 of file XML2Python.py.