Revision 57b5f922 ncclient/operations/rpc.py

b/ncclient/operations/rpc.py
15 15
from threading import Event, Lock
16 16
from uuid import uuid1
17 17

  
18
from ncclient import content
18
from ncclient import xml_
19 19
from ncclient.transport import SessionListener
20 20

  
21 21
from errors import OperationError, TimeoutExpiredError, MissingCapabilityError
......
55 55
        """Parse the *<rpc-reply>*"""
56 56
        if self._parsed:
57 57
            return
58
        root = self._root = content.xml2ele(self._raw) # <rpc-reply> element
58
        root = self._root = xml_.xml2ele(self._raw) # <rpc-reply> element
59 59
        # per rfc 4741 an <ok/> tag is sent when there are no errors or warnings
60
        ok = content.find(root, 'ok', nslist=[content.BASE_NS, content.CISCO_BS])
60
        ok = xml_.find(root, 'ok', nslist=[xml_.BASE_NS, xml_.CISCO_BS])
61 61
        if ok is not None:
62 62
            logger.debug('parsed [%s]' % ok.tag)
63 63
        else: # create RPCError objects from <rpc-error> elements
64
            error = content.find(root, 'rpc-error', nslist=[content.BASE_NS, content.CISCO_BS])
64
            error = xml_.find(root, 'rpc-error', nslist=[xml_.BASE_NS, xml_.CISCO_BS])
65 65
            if error is not None:
66 66
                logger.debug('parsed [%s]' % error.tag)
67 67
                for err in root.getiterator(error.tag):
68 68
                    # process a particular <rpc-error>
69 69
                    d = {}
70 70
                    for err_detail in err.getchildren(): # <error-type> etc..
71
                        tag = content.unqualify(err_detail.tag)
71
                        tag = xml_.unqualify(err_detail.tag)
72 72
                        if tag != 'error-info':
73 73
                            d[tag] = err_detail.text.strip()
74 74
                        else:
75
                            d[tag] = content.ele2xml(err_detail)
75
                            d[tag] = xml_.ele2xml(err_detail)
76 76
                    self._errors.append(RPCError(d))
77 77
        self._parsing_hook(root)
78 78
        self._parsed = True
......
198 198

  
199 199
    def callback(self, root, raw):
200 200
        tag, attrs = root
201
        if content.unqualify(tag) != 'rpc-reply':
201
        if xml_.unqualify(tag) != 'rpc-reply':
202 202
            return
203 203
        rpc = None
204 204
        for key in attrs:
205
            if content.unqualify(key) == 'message-id':
205
            if xml_.unqualify(key) == 'message-id':
206 206
                id = attrs[key]
207 207
                try:
208 208
                    with self._lock:
......
272 272
        spec = {
273 273
            'tag': 'rpc',
274 274
            'attrib': {
275
                'xmlns': content.BASE_NS,
275
                'xmlns': xml_.BASE_NS,
276 276
                'message-id': self._id
277 277
                },
278 278
            'subtree': [ opspec ]
279 279
            }
280
        return content.dtree2xml(spec)
280
        return xml_.dtree2xml(spec)
281 281

  
282 282
    def _request(self, op):
283 283
        """Subclasses call this method to make the RPC request.

Also available in: Unified diff