CMS 3D CMS Logo

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__ (self, **kwargs)
 
def __init__ (self, **kwargs)
 
def characters (self, content)
 
def characters (self, content)
 
def endElement (self, name)
 
def endElement (self, name)
 
def root (self)
 
def root (self)
 
def startElement (self, name, attrs)
 
def startElement (self, name, attrs)
 
def topLevel (self)
 
def topLevel (self)
 

Public Attributes

 current
 

Static Public Attributes

 non_id_char
 

Static Private Member Functions

def _name_mangle (name)
 
def _name_mangle (name)
 

Private Attributes

 _ncDict
 
 _root
 
 _stack
 
 _text_parts
 

Detailed Description

Definition at line 160 of file XML2Python.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

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

Definition at line 164 of file XML2Python.py.

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
170 

Referenced by XML2Python.TreeBuilder.__init__().

◆ __init__() [2/2]

def 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 

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

Member Function Documentation

◆ _name_mangle() [1/2]

def 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 

References XML2Python.TreeBuilder._name_mangle(), XML2Python.fixQuoteValue(), and XML2Python.xml2obj().

◆ _name_mangle() [2/2]

def XML2Python.TreeBuilder._name_mangle (   name)
staticprivate

Definition at line 203 of file XML2Python.py.

203  def _name_mangle (name):
204  return TreeBuilder.non_id_char.sub('_', name)
205 
206 

Referenced by XML2Python.TreeBuilder._name_mangle().

◆ characters() [1/2]

def 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 

References XML2Python.TreeBuilder._text_parts, mps_setup.append, and XML2Python.TreeBuilder.characters().

◆ characters() [2/2]

def XML2Python.TreeBuilder.characters (   self,
  content 
)

Definition at line 191 of file XML2Python.py.

191  def characters (self, content):
192  self._text_parts.append(content)
193 

References XML2Python.TreeBuilder._text_parts, and mps_setup.append.

Referenced by XML2Python.TreeBuilder.characters().

◆ endElement() [1/2]

def XML2Python.TreeBuilder.endElement (   self,
  name 
)

Definition at line 84 of file XML2Python.py.

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 

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

◆ endElement() [2/2]

def XML2Python.TreeBuilder.endElement (   self,
  name 
)

Definition at line 179 of file XML2Python.py.

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)
190 

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

Referenced by XML2Python.TreeBuilder.endElement().

◆ root() [1/2]

def XML2Python.TreeBuilder.root (   self)

Definition at line 99 of file XML2Python.py.

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

References XML2Python.TreeBuilder._root, and XML2Python.TreeBuilder.root().

◆ root() [2/2]

def XML2Python.TreeBuilder.root (   self)

Definition at line 194 of file XML2Python.py.

194  def root (self):
195  return self._root
196 

References XML2Python.TreeBuilder._root.

Referenced by XML2Python.TreeBuilder.root().

◆ startElement() [1/2]

def XML2Python.TreeBuilder.startElement (   self,
  name,
  attrs 
)

Definition at line 76 of file XML2Python.py.

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 

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

◆ startElement() [2/2]

def XML2Python.TreeBuilder.startElement (   self,
  name,
  attrs 
)

Definition at line 171 of file XML2Python.py.

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)
178 

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

Referenced by XML2Python.TreeBuilder.startElement().

◆ topLevel() [1/2]

def XML2Python.TreeBuilder.topLevel (   self)
Returns top level object

Definition at line 102 of file XML2Python.py.

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

References XML2Python.TreeBuilder._root, XML2Python.TreeBuilder.topLevel(), and contentValuesCheck.values.

◆ topLevel() [2/2]

def XML2Python.TreeBuilder.topLevel (   self)
Returns top level object

Definition at line 197 of file XML2Python.py.

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

References XML2Python.TreeBuilder._root, and contentValuesCheck.values.

Referenced by XML2Python.TreeBuilder.topLevel().

Member Data Documentation

◆ _ncDict

XML2Python.TreeBuilder._ncDict
private

◆ _root

XML2Python.TreeBuilder._root
private

◆ _stack

XML2Python.TreeBuilder._stack
private

◆ _text_parts

XML2Python.TreeBuilder._text_parts
private

◆ current

XML2Python.TreeBuilder.current

◆ non_id_char

XML2Python.TreeBuilder.non_id_char
static

Definition at line 162 of file XML2Python.py.

digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
mps_setup.append
append
Definition: mps_setup.py:85
root
Definition: RooFitFunction.h:10