Revision 216bb34c ncclient/operations/retrieve.py
b/ncclient/operations/retrieve.py | ||
---|---|---|
20 | 20 |
|
21 | 21 |
class GetReply(RPCReply): |
22 | 22 |
|
23 |
"""Adds attributes for the *<data>* element to :class:`RPCReply`, pertinent
|
|
24 |
to the *<get>* or *<get-config>* operations."""
|
|
23 |
"""Adds attributes for the *<data>* element to :class:`RPCReply`, which
|
|
24 |
pertains to the :class:`Get` and :class:`GetConfig` operations."""
|
|
25 | 25 |
|
26 | 26 |
def _parsing_hook(self, root): |
27 | 27 |
self._data = None |
... | ... | |
32 | 32 |
|
33 | 33 |
@property |
34 | 34 |
def data_ele(self): |
35 |
"As an :class:`~xml.etree.ElementTree.Element`"
|
|
35 |
"*<data>* element as an :class:`~xml.etree.ElementTree.Element`"
|
|
36 | 36 |
if not self._parsed: |
37 | 37 |
self.parse() |
38 | 38 |
return self._data |
39 | 39 |
|
40 | 40 |
@property |
41 | 41 |
def data_xml(self): |
42 |
"As an XML string"
|
|
42 |
"*<data>* element as an XML string"
|
|
43 | 43 |
if not self._parsed: |
44 | 44 |
self.parse() |
45 | 45 |
return content.ele2xml(self._data) |
46 | 46 |
|
47 |
@property |
|
48 |
def data_dtree(self): |
|
49 |
"*<data>* element in :ref:`dtree`" |
|
50 |
return content.ele2dtree(self._data) |
|
51 |
|
|
52 |
#: Same as :attr:`data_ele` |
|
47 | 53 |
data = data_ele |
48 | 54 |
|
49 | 55 |
|
50 | 56 |
class Get(RPC): |
51 | 57 |
|
52 |
"*<get>* RPC" |
|
58 |
"The *<get>* RPC"
|
|
53 | 59 |
|
54 |
SPEC = { |
|
55 |
'tag': 'get', |
|
56 |
'subtree': [] |
|
57 |
} |
|
60 |
SPEC = {'tag': 'get', 'subtree': []} |
|
58 | 61 |
|
59 | 62 |
REPLY_CLS = GetReply |
60 | 63 |
|
61 | 64 |
def request(self, filter=None): |
65 |
""" |
|
66 |
:arg filter: optional; see :ref:`filter` |
|
67 |
|
|
68 |
:seealso: :ref:`return` |
|
69 |
""" |
|
62 | 70 |
spec = Get.SPEC.copy() |
63 | 71 |
if filter is not None: |
64 | 72 |
spec['subtree'].append(util.build_filter(filter)) |
... | ... | |
67 | 75 |
|
68 | 76 |
class GetConfig(RPC): |
69 | 77 |
|
70 |
"*<get-config>* RPC" |
|
78 |
"The *<get-config>* RPC"
|
|
71 | 79 |
|
72 |
SPEC = { |
|
73 |
'tag': 'get-config', |
|
74 |
'subtree': [] |
|
75 |
} |
|
80 |
SPEC = {'tag': 'get-config', 'subtree': []} |
|
76 | 81 |
|
77 | 82 |
REPLY_CLS = GetReply |
78 | 83 |
|
79 | 84 |
def request(self, source, filter=None): |
85 |
""" |
|
86 |
:arg source: See :ref:`source_target` |
|
87 |
|
|
88 |
:arg filter: optional; see :ref:`filter` |
|
89 |
|
|
90 |
:seealso: :ref:`return` |
|
91 |
""" |
|
80 | 92 |
spec = GetConfig.SPEC.copy() |
81 | 93 |
spec['subtree'].append(util.store_or_url('source', source, self._assert)) |
82 | 94 |
if filter is not None: |
Also available in: Unified diff