Revision a7cb58ce ncclient/operations/retrieve.py

b/ncclient/operations/retrieve.py
19 19
import util
20 20

  
21 21
class GetReply(RPCReply):
22
    
23
    'Adds data attribute'
24
    
25
    # tested: no
26
    # combed: yes
27
    
22

  
23
    """Adds attributes for the *<data>* element to :class:`RPCReply`, pertinent
24
    to the *<get>* or *<get-config>* operations."""
25

  
28 26
    def _parsing_hook(self, root):
29 27
        self._data = None
30 28
        if not self._errors:
31
            self._data = content.find(root, 'data', nslist=[content.BASE_NS, content.CISCO_BS])
32
    
29
            self._data = content.find(root, 'data',
30
                                      nslist=[content.BASE_NS,
31
                                              content.CISCO_BS])
32

  
33 33
    @property
34
    def data(self):
34
    def data_ele(self):
35
        "As an :class:`~xml.etree.ElementTree.Element`"
35 36
        if not self._parsed:
36 37
            self.parse()
37 38
        return self._data
38 39

  
40
    @property
41
    def data_xml(self):
42
        "As an XML string"
43
        if not self._parsed:
44
            self.parse()
45
        return content.ele2xml(self._data)
46

  
47
    data = data_ele
48

  
49

  
39 50
class Get(RPC):
40
    
41
    # tested: no
42
    # combed: yes
43
    
51

  
52
    "*<get>* RPC"
53

  
44 54
    SPEC = {
45 55
        'tag': 'get',
46 56
        'subtree': []
47 57
    }
48
    
58

  
49 59
    REPLY_CLS = GetReply
50
    
60

  
51 61
    def request(self, filter=None):
52 62
        spec = Get.SPEC.copy()
53 63
        if filter is not None:
......
57 67

  
58 68
class GetConfig(RPC):
59 69

  
60
    # tested: no
61
    # combed: yes
62
    
70
    "*<get-config>* RPC"
71

  
63 72
    SPEC = {
64 73
        'tag': 'get-config',
65 74
        'subtree': []
66 75
    }
67
    
76

  
68 77
    REPLY_CLS = GetReply
69
    
78

  
70 79
    def request(self, source, filter=None):
71
        """
72
        `filter` has to be a tuple of (type, criteria)
73
        The type may be one of 'xpath' or 'subtree'
74
        The criteria may be an ElementTree.Element, an XML fragment, or tree specification
75
        """
76 80
        spec = GetConfig.SPEC.copy()
77 81
        spec['subtree'].append(util.store_or_url('source', source, self._assert))
78 82
        if filter is not None:

Also available in: Unified diff