Revision 965788a7

b/README
1
To install:
2
$ python setup.py install
b/docs/source/userdoc.rst
8 8

  
9 9
    userdoc/manager
10 10
    userdoc/capabilities
11
    userdoc/content
11
    userdoc/xml
12 12
    userdoc/transport
13 13
    userdoc/operations
/dev/null
1
**********************
2
:mod:`content` module
3
**********************
4

  
5
.. automodule:: ncclient.content
6
    :synopsis: Content layer
7

  
8
Namespaces
9
==========
10

  
11
The following namespace is defined in this module.
12

  
13
.. autodata:: BASE_NS
14

  
15
Namespaces are handled just the same way as :mod:`~xml.etree.ElementTree`. So a qualified name takes the form *{namespace}tag*. There are some utility functions for qualified names:
16

  
17
.. function:: qualify(tag[, ns=BASE_NS])
18
    
19
    :returns: qualified name
20

  
21
.. function:: unqualify(tag)
22
    
23
    :returns: unqualified name
24
    
25
    .. note:: It is strongly recommended to compare qualified names.
26

  
27
.. _dtree:
28

  
29
DictTree XML representation
30
===========================
31

  
32
.. note::
33
    Where this representation is stipulated, an XML literal or :class:`~xml.etree.ElementTree.Element` is just fine as well.
34

  
35
:mod:`ncclient` can make use of a special syntax for XML based on Python dictionaries. It is best illustrated through an example::
36
    
37
    dtree = {
38
        'tag': qualify('a', 'some_namespace'),
39
        'attrib': {'attr': 'val'},
40
        'subtree': [ { 'tag': 'child1' }, { 'tag': 'child2', 'text': 'some text' } ]
41
    }
42

  
43
Calling :func:`dtree2xml` on *dtree* would return
44

  
45
.. code-block:: xml
46

  
47
    <?xml version="1.0" encoding="UTF-8"?>
48
    <ns0:a attr="val" xmlns:ns0="some_namespace">
49
        <child1 />
50
        <child2>some text</child2>
51
    </ns0:a>
52
    
53
In addition to a 'pure' dictionary representation a DictTree node (including the root) may be an XML literal or an :class:`~xml.etree.ElementTree.Element` instance. The above example could thus be equivalently written as::
54

  
55
    dtree2 = {
56
        'tag': '{ns}a',
57
        'attrib': {'attr': 'val'},
58
        'subtree': [ ET.Element('child1'), '<child2>some text</child2>' ]
59
    }
60

  
61
Converting between different representations
62
============================================
63

  
64
Conversions *to* DictTree representation are guaranteed to be entirely dictionaries. In converting *from* DictTree representation, the argument may be any valid representation as specified.
65

  
66
.. autofunction:: dtree2ele(spec)
67

  
68
.. autofunction:: dtree2xml(spec[, encoding="UTF-8"])
69

  
70
.. autofunction:: ele2dtree(ele)
71
    
72
.. autofunction:: ele2xml(ele)
73

  
74
.. autofunction:: xml2dtree(xml)
75

  
76
.. autofunction:: xml2ele(xml)
77

  
78
Other utility functions
79
========================
80

  
81
.. autofunction:: iselement(obj)
82

  
83
    :see: :meth:`xml.etree.ElementTree.iselement`
84

  
85
.. autofunction:: find(ele, tag[, nslist=[]])
86

  
87
.. autofunction:: parse_root(raw)
88

  
89
.. autofunction:: validated_element(rep, tag=None, attrs=None, text=None)
90

  
91

  
92
Errors
93
======
94

  
95
.. autoexception:: ContentError
96
    :show-inheritance:
97
    :members:
98

  
b/docs/source/userdoc/xml.rst
1
**********************
2
:mod:`content` module
3
**********************
4

  
5
.. automodule:: ncclient.xml_
6
    :synopsis: XML facilities
7

  
8
Namespaces
9
==========
10

  
11
The following namespace is defined in this module.
12

  
13
.. autodata:: BASE_NS
14

  
15
Namespaces are handled just the same way as :mod:`~xml.etree.ElementTree`. So a qualified name takes the form *{namespace}tag*. There are some utility functions for qualified names:
16

  
17
.. function:: qualify(tag[, ns=BASE_NS])
18
    
19
    :returns: qualified name
20

  
21
.. function:: unqualify(tag)
22
    
23
    :returns: unqualified name
24
    
25
    .. note:: It is strongly recommended to compare qualified names.
26

  
27
.. _dtree:
28

  
29
DictTree XML representation
30
===========================
31

  
32
.. note::
33
    Where this representation is stipulated, an XML literal or :class:`~xml.etree.ElementTree.Element` is just fine as well.
34

  
35
:mod:`ncclient` can make use of a special syntax for XML based on Python dictionaries. It is best illustrated through an example::
36
    
37
    dtree = {
38
        'tag': qualify('a', 'some_namespace'),
39
        'attrib': {'attr': 'val'},
40
        'subtree': [ { 'tag': 'child1' }, { 'tag': 'child2', 'text': 'some text' } ]
41
    }
42

  
43
Calling :func:`dtree2xml` on *dtree* would return
44

  
45
.. code-block:: xml
46

  
47
    <?xml version="1.0" encoding="UTF-8"?>
48
    <ns0:a attr="val" xmlns:ns0="some_namespace">
49
        <child1 />
50
        <child2>some text</child2>
51
    </ns0:a>
52
    
53
In addition to a 'pure' dictionary representation a DictTree node (including the root) may be an XML literal or an :class:`~xml.etree.ElementTree.Element` instance. The above example could thus be equivalently written as::
54

  
55
    dtree2 = {
56
        'tag': '{ns}a',
57
        'attrib': {'attr': 'val'},
58
        'subtree': [ ET.Element('child1'), '<child2>some text</child2>' ]
59
    }
60

  
61
Converting between different representations
62
============================================
63

  
64
Conversions *to* DictTree representation are guaranteed to be entirely dictionaries. In converting *from* DictTree representation, the argument may be any valid representation as specified.
65

  
66
.. autofunction:: dtree2ele(spec)
67

  
68
.. autofunction:: dtree2xml(spec[, encoding="UTF-8"])
69

  
70
.. autofunction:: ele2dtree(ele)
71
    
72
.. autofunction:: ele2xml(ele)
73

  
74
.. autofunction:: xml2dtree(xml)
75

  
76
.. autofunction:: xml2ele(xml)
77

  
78
Other utility functions
79
========================
80

  
81
.. autofunction:: iselement(obj)
82

  
83
    :see: :meth:`xml.etree.ElementTree.iselement`
84

  
85
.. autofunction:: find(ele, tag[, nslist=[]])
86

  
87
.. autofunction:: parse_root(raw)
88

  
89
.. autofunction:: validated_element(rep, tag=None, attrs=None, text=None)
90

  
91

  
92
Errors
93
======
94

  
95
.. autoexception:: ContentError
96
    :show-inheritance:
97
    :members:
98

  
b/ncclient/__init__.py
14 14

  
15 15
import sys
16 16

  
17
# actually no reason why shouldn't work on 2.5 but that's... untested -- TODO
18 17
if sys.version_info < (2, 6):
19 18
    raise RuntimeError('You need Python 2.6+ for this module.')
20 19

  
b/setup.py
1
# Copyright 2009 Shikhar Bhushan
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#    http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

  
15
from distutils.core import setup
16

  
17
setup(name='ncclient',
18
      version='0.1.0',
19
      description="Python library for NETCONF clients",
20
      author="Shikhar Bhushan",
21
      author_email="shikhar@schmizz.net",
22
      url="http://code.google.com/p/ncclient/",
23
      packages=["ncclient", "ncclient/transport", "ncclient/operations"],
24
      license="Apache License 2.0",
25
      platforms=["Posix; OS X; Windows"],
26
      #classifiers=[]
27
      )

Also available in: Unified diff