Public Member Functions | |
def | __contains__ |
def | __contains__ |
def | __getattr__ |
def | __getattr__ |
def | __getitem__ |
def | __getitem__ |
def | __init__ |
def | __init__ |
def | __len__ |
def | __len__ |
def | __nonzero__ |
def | __nonzero__ |
def | __repr__ |
def | __repr__ |
def | __str__ |
def | __str__ |
def | attributes |
def | attributes |
def | isiterable |
def | stringify |
Static Public Attributes | |
int | spaces = 4 |
Private Member Functions | |
def | _add_xml_attr |
def | _add_xml_attr |
def | _outputValues |
Private Attributes | |
_attrs | |
_data | |
_ncDict |
Definition at line 10 of file XML2Python.py.
def XML2Python::DataNode::__init__ | ( | self, | |
kwargs | |||
) |
Definition at line 14 of file XML2Python.py.
def XML2Python::DataNode::__init__ | ( | self, | |
kwargs | |||
) |
Definition at line 11 of file XML2Python.py.
def XML2Python::DataNode::__contains__ | ( | self, | |
name | |||
) |
Definition at line 32 of file XML2Python.py.
def XML2Python::DataNode::__contains__ | ( | self, | |
name | |||
) |
Definition at line 26 of file XML2Python.py.
def XML2Python::DataNode::__getattr__ | ( | self, | |
name | |||
) |
Definition at line 40 of file XML2Python.py.
def XML2Python::DataNode::__getattr__ | ( | self, | |
name | |||
) |
Definition at line 32 of file XML2Python.py.
def XML2Python::DataNode::__getitem__ | ( | self, | |
key | |||
) |
Definition at line 25 of file XML2Python.py.
def XML2Python::DataNode::__getitem__ | ( | self, | |
key | |||
) |
Definition at line 20 of file XML2Python.py.
def XML2Python::DataNode::__len__ | ( | self | ) |
Definition at line 20 of file XML2Python.py.
def XML2Python::DataNode::__len__ | ( | self | ) |
Definition at line 16 of file XML2Python.py.
def XML2Python::DataNode::__nonzero__ | ( | self | ) |
Definition at line 36 of file XML2Python.py.
def XML2Python::DataNode::__nonzero__ | ( | self | ) |
Definition at line 29 of file XML2Python.py.
def XML2Python::DataNode::__repr__ | ( | self | ) |
Definition at line 66 of file XML2Python.py.
def XML2Python::DataNode::__repr__ | ( | self | ) |
Definition at line 55 of file XML2Python.py.
def XML2Python::DataNode::__str__ | ( | self | ) |
Definition at line 52 of file XML2Python.py.
def XML2Python::DataNode::__str__ | ( | self | ) |
Definition at line 62 of file XML2Python.py.
def XML2Python::DataNode::_add_xml_attr | ( | self, | |
name, | |||
value | |||
) | [private] |
Definition at line 38 of file XML2Python.py.
00039 : 00040 change = self._ncDict.get (name) 00041 if change: 00042 name = change 00043 if name in self._attrs: 00044 # multiple attribute of the same name are represented by a list 00045 children = self._attrs[name] 00046 if not isinstance(children, list): 00047 children = [children] 00048 self._attrs[name] = children 00049 children.append(value) 00050 else: 00051 self._attrs[name] = value
def XML2Python::DataNode::_add_xml_attr | ( | self, | |
name, | |||
value | |||
) | [private] |
Definition at line 47 of file XML2Python.py.
00048 : 00049 change = self._ncDict.get (name) 00050 if change: 00051 name = change 00052 if name in self._attrs: 00053 # multiple attribute of the same name are represented by a list 00054 children = self._attrs[name] 00055 if not isinstance(children, list): 00056 children = [children] 00057 self._attrs[name] = children 00058 children.append(value) 00059 else: 00060 self._attrs[name] = value 00061
def XML2Python::DataNode::_outputValues | ( | obj, | |
name, | |||
offset | |||
) | [private] |
Definition at line 83 of file XML2Python.py.
00084 : 00085 retval = ' ' * offset 00086 if name: 00087 retval += '%s: ' % name 00088 offset += len (name) + DataNode.spaces 00089 # if this is a list 00090 if isinstance (obj, list): 00091 first = True 00092 for value in obj: 00093 print "value", value, value.__class__.__name__ 00094 if first: 00095 tempoffset = offset 00096 first = False 00097 retval += '[\n ' + ' ' * offset 00098 else: 00099 retval += ',\n ' + ' ' * offset 00100 tempoffset = offset 00101 if isinstance (value, DataNode): 00102 retval += value.stringify (offset=tempoffset) 00103 print " calling stringify for %s" % value 00104 elif DataNode.isiterable (value): 00105 retval += DataNode._outputValues (value, '', offset) 00106 else: 00107 retval += "%s" % value 00108 retval += '\n' + ' ' * (offset - 2) +']\n' 00109 return retval 00110 retval += pprint.pformat(obj, 00111 indent= offset, 00112 width=1) 00113 return retval 00114
def XML2Python::DataNode::attributes | ( | self | ) |
Definition at line 73 of file XML2Python.py.
def XML2Python::DataNode::attributes | ( | self | ) |
Definition at line 61 of file XML2Python.py.
def XML2Python::DataNode::isiterable | ( | obj | ) |
Definition at line 78 of file XML2Python.py.
def XML2Python::DataNode::stringify | ( | self, | |
name = '' , |
|||
offset = 0 |
|||
) |
Definition at line 115 of file XML2Python.py.
00116 : 00117 # is this just data and nothing below 00118 if self._data and not len (self._attrs): 00119 return _outputValues (self._data, name, offset) 00120 retval = ' ' * offset 00121 if name: 00122 retval += '%s : %s\n' % \ 00123 (name, 00124 pprint.pformat (self._data, 00125 indent= offset+DataNode.spaces, 00126 width=1) ) 00127 else: 00128 retval += pprint.pformat (self._data, 00129 indent=offset+DataNode.spaces, 00130 width=1) 00131 return retval 00132 # this has attributes 00133 retval = '' 00134 if name: 00135 retval += '\n' + ' ' * offset 00136 retval += '%s: ' % name 00137 first = True 00138 for key, value in sorted (self._attrs.iteritems()): 00139 if first: 00140 retval += '{ \n' 00141 tempspace = offset + 3 00142 first = False 00143 else: 00144 retval += ',\n' 00145 tempspace = offset + 3 00146 if isinstance (value, DataNode): 00147 retval += value.stringify (key, tempspace) 00148 else: 00149 retval += DataNode._outputValues (value, key, tempspace) 00150 # this has data too 00151 if self._data: 00152 retval += ',\n' 00153 tempspace = offset + 3 00154 retval += DataNode._ouptputValues (self._data, name, tempspace) 00155 retval += '\n ' + ' ' * offset + '}' 00156 return retval 00157 00158
XML2Python::DataNode::_attrs [private] |
Definition at line 14 of file XML2Python.py.
XML2Python::DataNode::_data [private] |
Definition at line 14 of file XML2Python.py.
XML2Python::DataNode::_ncDict [private] |
Definition at line 14 of file XML2Python.py.
int XML2Python::DataNode::spaces = 4 [static] |
Definition at line 12 of file XML2Python.py.