Revision 4de03d63 ncclient/content.py

b/ncclient/content.py
12 12
# See the License for the specific language governing permissions and
13 13
# limitations under the License.
14 14

  
15
from cStringIO import StringIO
15 16
from xml.etree import cElementTree as ET
16 17

  
17 18
from ncclient import NCClientError
......
44 45

  
45 46
### XML with Python data structures
46 47

  
47
dtree2ele = DictTree.Element
48
dtree2xml = DictTree.XML
49
ele2dtree = Element.DictTree
50
ele2xml = Element.XML
51
xml2dtree = XML.DictTree
52
xml2ele = XML.Element
53

  
54 48
class DictTree:
55 49

  
56 50
    @staticmethod
......
78 72
            raise ContentError('Invalid tree spec')
79 73
    
80 74
    @staticmethod
81
    def XML(spec):
82
        Element.XML(DictTree.Element(spec))
75
    def XML(spec, encoding='utf-8'):
76
        Element.XML(DictTree.Element(spec), encoding)
83 77

  
84 78
class Element:
85 79
    
......
101 95
class XML:
102 96
    
103 97
    @staticmethod
104
    def DictTree(ele):
105
        return Element.DictTree(Element.XML(ele))
98
    def DictTree(xml):
99
        return Element.DictTree(XML.Element(xml))
106 100
    
107 101
    @staticmethod
108 102
    def Element(xml):
109 103
        return ET.fromstring(xml)
110 104

  
105
dtree2ele = DictTree.Element
106
dtree2xml = DictTree.XML
107
ele2dtree = Element.DictTree
108
ele2xml = Element.XML
109
xml2dtree = XML.DictTree
110
xml2ele = XML.Element
111

  
111 112
### Other utility functions
112 113

  
113 114
iselement = ET.iselement

Also available in: Unified diff