Revision ebf2bbc6 ncclient/operations/util.py

b/ncclient/operations/util.py
16 16

  
17 17
from ncclient import OperationError
18 18
from ncclient.content import qualify as _
19
from ncclient.content import ensure_root
19
from ncclient.content import root_ensured
20 20

  
21
from ncclient.errors import MissingCapabilityError, ArgumentError
21
from errors import MissingCapabilityError
22 22

  
23 23
def one_of(*args):
24 24
    'Verifies that only one of the arguments is not None'
......
31 31
                return
32 32
    raise OperationError('Insufficient parameters')
33 33

  
34
def store_or_url(store, url, capcheck_func=None):
34
def store_or_url(store, url, capcheck=None):
35 35
    one_of(store, url)
36 36
    node = {}
37 37
    if store is not None:
38 38
        node['tag'] = store
39 39
    else:
40
        if capcheck_func is not None:
41
            capcheck_func(':url') # hmm.. schema check? deem overkill for now
40
        if capcheck is not None:
41
            capcheck(':url') # hmm.. schema check? deem overkill for now
42 42
        node['tag'] = 'url'
43 43
        node['text'] = url
44 44
    return node
45 45

  
46
def build_filter(spec, capcheck=None):
47
    type = None
48
    if isinstance(spec, tuple):
49
        type, criteria = tuple
50
        rep = {
51
            'tag': 'filter',
52
            'attributes': {'type': type},
53
            'subtree': criteria
54
       }
55
    else:
56
        rep = root_ensure(spec, 'filter', 'type')
57
        try:
58
            type = rep['type']
59
        except KeyError:
60
            type = ele[qualify('type'))
61
    if type == 'xpath' and capcheck_func is not None:
62
        capcheck_func(':xpath')
63
    return rep
64

  

Also available in: Unified diff