Revision 216bb34c ncclient/operations/rpc.py

b/ncclient/operations/rpc.py
17 17
from weakref import WeakValueDictionary
18 18

  
19 19
from ncclient import content
20
from ncclient.capabilities import check
21 20
from ncclient.transport import SessionListener
22 21

  
23
from errors import OperationError
22
from errors import OperationError, TimeoutExpiredError, MissingCapabilityError
24 23

  
25 24
import logging
26 25
logger = logging.getLogger('ncclient.operations.rpc')
......
29 28
class RPCReply:
30 29

  
31 30
    """Represents an *<rpc-reply>*. Only concerns itself with whether the
32
    operation was successful. Note that if the reply has not yet been parsed
33
    there is a one-time parsing overhead to accessing the :attr:`ok` and
34
    :attr:`error`/:attr:`errors` attributes."""
31
    operation was successful.
32

  
33
    .. note::
34
        If the reply has not yet been parsed there is an implicit, one-time
35
        parsing overhead to accessing the attributes defined by this class and
36
        any subclasses.
37
    """
35 38

  
36 39
    def __init__(self, raw):
37 40
        self._raw = raw
......
89 92

  
90 93
    @property
91 94
    def error(self):
92
        "Short for :attr:`errors`[0], returning :const:`None` if there were no errors."
95
        """Short for :attr:`errors` [0]; :const:`None` if there were no errors.
96
        """
93 97
        if not self._parsed:
94 98
            self.parse()
95 99
        if self._errors:
......
99 103

  
100 104
    @property
101 105
    def errors(self):
102
        "List of :class:`RPCError` objects. Will be empty if there were no :class:`<rpc-error>` elements in reply."
106
        """`list` of :class:`RPCError` objects. Will be empty if there were no
107
        *<rpc-error>* elements in reply.
108
        """
103 109
        if not self._parsed:
104 110
            self.parse()
105 111
        return self._errors
......
225 231

  
226 232
class RPC(object):
227 233

  
228
    "Directly corresponds to *<rpc>* requests. Handles making the request, and taking delivery of the reply."
234
    """Base class for all operations.
235

  
236
    Directly corresponds to *<rpc>* requests. Handles making the request, and
237
    taking delivery of the reply.
238
    """
229 239

  
230 240
    # : Subclasses can specify their dependencies on capabilities. List of URI's
231 241
    # or abbreviated names, e.g. ':writable-running'. These are verified at the
......
291 301
                self._reply.parse()
292 302
                return self._reply
293 303
            else:
294
                raise ReplyTimeoutError
304
                raise TimeoutExpiredError
295 305

  
296 306
    def request(self, *args, **kwds):
297
        "Subclasses implement this method. Here, the operation is to be constructed as a :ref:`dtree`, and the result of :meth:`_request` returned."
298
        return self._request(self.SPEC, *args, **kwds)
307
        """Subclasses implement this method. Here, the operation is constructed
308
        in :ref:`dtree`, and the result of :meth:`_request` returned."""
309
        raise NotImplementedError
299 310

  
300 311
    def _delivery_hook(self):
301 312
        """Subclasses can implement this method. Will be called after
......
306 317
    def _assert(self, capability):
307 318
        """Subclasses can use this method to verify that a capability is available
308 319
        with the NETCONF server, before making a request that requires it. A
309
        :class:`MissingCapabilityError` will be raised if the capability is not
320
        :exc:`MissingCapabilityError` will be raised if the capability is not
310 321
        available."""
311 322
        if capability not in self._session.server_capabilities:
312 323
            raise MissingCapabilityError('Server does not support [%s]' % cap)

Also available in: Unified diff