CMS 3D CMS Logo

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

Public Member Functions

def __contains__
 
def __getattr__
 
def __getitem__
 
def __init__
 
def __len__
 
def __nonzero__
 
def __repr__
 
def __str__
 
def attributes
 

Private Member Functions

def _add_xml_attr
 

Private Attributes

 _attrs
 
 _data
 
 _ncDict
 

Detailed Description

Definition at line 9 of file XML2Python.py.

Constructor & Destructor Documentation

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

Definition at line 11 of file XML2Python.py.

11 
12  def __init__ (self, **kwargs):
13  self._attrs = {} # XML attributes and child elements
14  self._data = None # child text data
15  self._ncDict = kwargs.get ('nameChangeDict', {})

Member Function Documentation

def python.XML2Python.DataNode.__contains__ (   self,
  name 
)

Definition at line 26 of file XML2Python.py.

26 
27  def __contains__ (self, name):
28  return self._attrs.has_key(name)
def python.XML2Python.DataNode.__getattr__ (   self,
  name 
)

Definition at line 32 of file XML2Python.py.

32 
33  def __getattr__ (self, name):
34  if name.startswith('__'):
35  # need to do this for Python special methods???
36  raise AttributeError (name)
37  return self._attrs.get (name, None)
def python.XML2Python.DataNode.__getitem__ (   self,
  key 
)

Definition at line 20 of file XML2Python.py.

20 
21  def __getitem__ (self, key):
22  if isinstance (key, basestring):
23  return self._attrs.get(key,None)
24  else:
25  return [self][key]
def python.XML2Python.DataNode.__len__ (   self)

Definition at line 16 of file XML2Python.py.

16 
17  def __len__ (self):
18  # treat single element as a list of 1
19  return 1
def python.XML2Python.DataNode.__nonzero__ (   self)

Definition at line 29 of file XML2Python.py.

References python.XML2Python.DataNode._attrs, XML2Python.DataNode._attrs, python.XML2Python.DataNode._data, XML2Python.DataNode._data, HcalTriggerKey._data, DTBtiTrig._data, DTTracoTrig._data, BitArray< N >._data, and DTTFBitArray< N >._data.

29 
30  def __nonzero__ (self):
31  return bool (self._attrs or self._data)
def python.XML2Python.DataNode.__repr__ (   self)

Definition at line 55 of file XML2Python.py.

References python.XML2Python.DataNode._data, XML2Python.DataNode._data, HcalTriggerKey._data, DTBtiTrig._data, DTTracoTrig._data, DTTFBitArray< N >._data, BitArray< N >._data, and join().

55 
56  def __repr__ (self):
57  items = sorted (self._attrs.items())
58  if self._data:
59  items.append(('data', self._data))
60  return u'{%s}' % ', '.join([u'%s:%s' % (k,repr(v)) for k,v in items])
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def python.XML2Python.DataNode.__str__ (   self)

Definition at line 52 of file XML2Python.py.

References python.XML2Python.DataNode._data, XML2Python.DataNode._data, HcalTriggerKey._data, DTBtiTrig._data, DTTracoTrig._data, BitArray< N >._data, and DTTFBitArray< N >._data.

52 
53  def __str__ (self):
54  return self._data or ''
def python.XML2Python.DataNode._add_xml_attr (   self,
  name,
  value 
)
private

Definition at line 38 of file XML2Python.py.

References python.XML2Python.DataNode._attrs, and XML2Python.DataNode._attrs.

38 
39  def _add_xml_attr (self, name, value):
40  change = self._ncDict.get (name)
41  if change:
42  name = change
43  if name in self._attrs:
44  # multiple attribute of the same name are represented by a list
45  children = self._attrs[name]
46  if not isinstance(children, list):
47  children = [children]
48  self._attrs[name] = children
49  children.append(value)
50  else:
51  self._attrs[name] = value
def python.XML2Python.DataNode.attributes (   self)

Definition at line 61 of file XML2Python.py.

References python.XML2Python.DataNode._attrs, and XML2Python.DataNode._attrs.

61 
62  def attributes (self):
63  return self._attrs
64 

Member Data Documentation

python.XML2Python.DataNode._attrs
private

Definition at line 12 of file XML2Python.py.

Referenced by python.XML2Python.DataNode.__nonzero__(), python.XML2Python.DataNode._add_xml_attr(), and python.XML2Python.DataNode.attributes().

python.XML2Python.DataNode._data
private

Definition at line 13 of file XML2Python.py.

Referenced by python.XML2Python.DataNode.__nonzero__(), python.XML2Python.DataNode.__repr__(), and python.XML2Python.DataNode.__str__().

python.XML2Python.DataNode._ncDict
private

Definition at line 14 of file XML2Python.py.

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