Revision e52e8478
b/ncclient/content.py | ||
---|---|---|
73 | 73 |
|
74 | 74 |
@staticmethod |
75 | 75 |
def XML(spec, encoding='utf-8'): |
76 |
Element.XML(DictTree.Element(spec), encoding) |
|
76 |
return Element.XML(DictTree.Element(spec), encoding)
|
|
77 | 77 |
|
78 | 78 |
class Element: |
79 | 79 |
|
... | ... | |
90 | 90 |
@staticmethod |
91 | 91 |
def XML(ele, encoding='utf-8'): |
92 | 92 |
xml = ET.tostring(ele, encoding) |
93 |
return xml if xml.startswith('<?xml') else '<?xml version="1.0" encoding="%s"?>\n%s' % (encoding, xml) |
|
93 |
if xml.startswith('<?xml'): |
|
94 |
return xml |
|
95 |
else: |
|
96 |
return '<?xml version="1.0" encoding="%s"?>%s' % (encoding, xml) |
|
94 | 97 |
|
95 | 98 |
class XML: |
96 | 99 |
|
b/ncclient/operations/rpc.py | ||
---|---|---|
37 | 37 |
def __repr__(self): |
38 | 38 |
return self._raw |
39 | 39 |
|
40 |
def _parsing_hook(self, root): |
|
41 |
pass |
|
42 |
|
|
40 | 43 |
def parse(self): |
41 | 44 |
if self._parsed: |
42 | 45 |
return |
... | ... | |
225 | 228 |
self._reply = None |
226 | 229 |
self._reply_event = Event() |
227 | 230 |
|
228 |
def _build(self, opspec, encoding='utf-8'):
|
|
231 |
def _build(self, opspec): |
|
229 | 232 |
"TODO: docstring" |
230 | 233 |
spec = { |
231 | 234 |
'tag': content.qualify('rpc'), |
232 | 235 |
'attributes': {'message-id': self._id}, |
233 | 236 |
'subtree': opspec |
234 | 237 |
} |
235 |
return content.dtree2xml(encoding)
|
|
238 |
return content.dtree2xml(spec)
|
|
236 | 239 |
|
237 | 240 |
def _request(self, op): |
238 | 241 |
req = self._build(op) |
b/ncclient/transport/hello.py | ||
---|---|---|
41 | 41 |
'tag': content.qualify('hello'), |
42 | 42 |
'subtree': [{ |
43 | 43 |
'tag': 'capabilities', |
44 |
'children': # this is fun :-)
|
|
44 |
'subtree': # this is fun :-)
|
|
45 | 45 |
[{'tag': 'capability', 'text': uri} for uri in capabilities] |
46 | 46 |
}] |
47 | 47 |
} |
... | ... | |
61 | 61 |
if content.unqualify(cap.tag) == 'capability': |
62 | 62 |
capabilities.append(cap.text) |
63 | 63 |
return sid, capabilities |
64 |
|
|
65 |
''' |
|
66 |
from ncclient.capabilities import CAPABILITIES |
|
67 |
from ncclient.transport.hello import HelloHandler |
|
68 |
|
|
69 |
print HelloHandler.build(CAPABILITIES) |
|
70 |
''' |
Also available in: Unified diff