CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | Private Attributes
python.XML2Python.TreeBuilder Class Reference
Inheritance diagram for python.XML2Python.TreeBuilder:

Public Member Functions

def __init__ (self, kwargs)
 
def characters (self, content)
 
def endElement (self, name)
 
def root (self)
 
def startElement (self, name, attrs)
 
def topLevel (self)
 

Public Attributes

 current
 

Static Public Attributes

 non_id_char
 

Static Private Member Functions

def _name_mangle (name)
 

Private Attributes

 _ncDict
 
 _root
 
 _stack
 
 _text_parts
 

Detailed Description

Definition at line 65 of file XML2Python.py.

Constructor & Destructor Documentation

def python.XML2Python.TreeBuilder.__init__ (   self,
  kwargs 
)

Definition at line 69 of file XML2Python.py.

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

Member Function Documentation

def python.XML2Python.TreeBuilder._name_mangle (   name)
staticprivate

Definition at line 108 of file XML2Python.py.

108  def _name_mangle (name):
109  return TreeBuilder.non_id_char.sub('_', name)
110 
111 
def python.XML2Python.TreeBuilder.characters (   self,
  content 
)

Definition at line 96 of file XML2Python.py.

96  def characters (self, content):
97  self._text_parts.append(content)
98 
def characters(self, content)
Definition: XML2Python.py:96
def python.XML2Python.TreeBuilder.endElement (   self,
  name 
)

Definition at line 84 of file XML2Python.py.

References python.XML2Python.TreeBuilder._text_parts, XML2Python.TreeBuilder._text_parts, python.XML2Python.TreeBuilder.current, XML2Python.TreeBuilder.current, svgfig.Curve.Samples.current, and digitizers_cfi.strip.

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

Definition at line 99 of file XML2Python.py.

References python.XML2Python.TreeBuilder._root, and XML2Python.TreeBuilder._root.

99  def root (self):
100  return self._root
101 
def python.XML2Python.TreeBuilder.startElement (   self,
  name,
  attrs 
)

Definition at line 76 of file XML2Python.py.

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

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

Definition at line 102 of file XML2Python.py.

References MuonErrorMatrixValues_cff.values.

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

Member Data Documentation

python.XML2Python.TreeBuilder._ncDict
private

Definition at line 72 of file XML2Python.py.

Referenced by python.XML2Python.TreeBuilder.startElement().

python.XML2Python.TreeBuilder._root
private

Definition at line 73 of file XML2Python.py.

Referenced by python.XML2Python.TreeBuilder.root().

python.XML2Python.TreeBuilder._stack
private

Definition at line 70 of file XML2Python.py.

python.XML2Python.TreeBuilder._text_parts
private
python.XML2Python.TreeBuilder.current
python.XML2Python.TreeBuilder.non_id_char
static

Definition at line 67 of file XML2Python.py.