Revision 57b5f922 ncclient/transport/session.py
b/ncclient/transport/session.py | ||
---|---|---|
15 | 15 |
from Queue import Queue |
16 | 16 |
from threading import Thread, Lock, Event |
17 | 17 |
|
18 |
from ncclient import content
|
|
18 |
from ncclient import xml_
|
|
19 | 19 |
from ncclient.capabilities import Capabilities |
20 | 20 |
|
21 | 21 |
from errors import TransportError |
... | ... | |
43 | 43 |
|
44 | 44 |
def _dispatch_message(self, raw): |
45 | 45 |
try: |
46 |
root = content.parse_root(raw)
|
|
46 |
root = xml_.parse_root(raw)
|
|
47 | 47 |
except Exception as e: |
48 | 48 |
logger.error('error parsing dispatch message: %s' % e) |
49 | 49 |
return |
... | ... | |
211 | 211 |
self._error_cb = error_cb |
212 | 212 |
|
213 | 213 |
def callback(self, root, raw): |
214 |
if content.unqualify(root[0]) == 'hello':
|
|
214 |
if xml_.unqualify(root[0]) == 'hello':
|
|
215 | 215 |
try: |
216 | 216 |
id, capabilities = HelloHandler.parse(raw) |
217 | 217 |
except Exception as e: |
... | ... | |
227 | 227 |
"Given a list of capability URI's returns <hello> message XML string" |
228 | 228 |
spec = { |
229 | 229 |
'tag': 'hello', |
230 |
'attrib': {'xmlns': content.BASE_NS},
|
|
230 |
'attrib': {'xmlns': xml_.BASE_NS},
|
|
231 | 231 |
'subtree': [{ |
232 | 232 |
'tag': 'capabilities', |
233 | 233 |
'subtree': # this is fun :-) |
234 | 234 |
[{'tag': 'capability', 'text': uri} for uri in capabilities] |
235 | 235 |
}] |
236 | 236 |
} |
237 |
return content.dtree2xml(spec)
|
|
237 |
return xml_.dtree2xml(spec)
|
|
238 | 238 |
|
239 | 239 |
@staticmethod |
240 | 240 |
def parse(raw): |
241 | 241 |
"Returns tuple of (session-id (str), capabilities (Capabilities)" |
242 | 242 |
sid, capabilities = 0, [] |
243 |
root = content.xml2ele(raw)
|
|
243 |
root = xml_.xml2ele(raw)
|
|
244 | 244 |
for child in root.getchildren(): |
245 |
tag = content.unqualify(child.tag)
|
|
245 |
tag = xml_.unqualify(child.tag)
|
|
246 | 246 |
if tag == 'session-id': |
247 | 247 |
sid = child.text |
248 | 248 |
elif tag == 'capabilities': |
249 | 249 |
for cap in child.getchildren(): |
250 |
if content.unqualify(cap.tag) == 'capability':
|
|
250 |
if xml_.unqualify(cap.tag) == 'capability':
|
|
251 | 251 |
capabilities.append(cap.text) |
252 | 252 |
return sid, Capabilities(capabilities) |
Also available in: Unified diff