Revision cc9af1c3 ncclient/operations/util.py
b/ncclient/operations/util.py | ||
---|---|---|
12 | 12 |
# See the License for the specific language governing permissions and |
13 | 13 |
# limitations under the License. |
14 | 14 |
|
15 |
'Boilerplate' |
|
15 |
'Boilerplate ugliness'
|
|
16 | 16 |
|
17 | 17 |
from ncclient import OperationError |
18 |
from ncclient.content import qualify as _ |
|
19 |
from ncclient.content import ensure_root |
|
18 | 20 |
|
19 |
from . import MissingCapabilityError
|
|
21 |
from ncclient.errors import MissingCapabilityError, ArgumentError
|
|
20 | 22 |
|
21 | 23 |
def one_of(*args): |
22 | 24 |
'Verifies that only one of the arguments is not None' |
... | ... | |
29 | 31 |
return |
30 | 32 |
raise OperationError('Insufficient parameters') |
31 | 33 |
|
32 |
def store_or_url(store, url): |
|
34 |
def store_or_url(store, url, capcheck_func=None):
|
|
33 | 35 |
one_of(store, url) |
34 | 36 |
node = {} |
35 | 37 |
if store is not None: |
36 | 38 |
node['tag'] = store |
37 | 39 |
else: |
40 |
if capcheck_func is not None: |
|
41 |
capcheck_func(':url') # hmm.. schema check? deem overkill for now |
|
38 | 42 |
node['tag'] = 'url' |
39 | 43 |
node['text'] = url |
40 | 44 |
return node |
41 | 45 |
|
42 |
def build_filter(type, criteria): |
|
43 |
filter = { |
|
44 |
'tag': 'filter', |
|
45 |
'attributes': {'type': type} |
|
46 |
} |
|
47 |
if type == 'xpath': |
|
48 |
filter['attributes']['select'] = criteria |
|
49 |
else: |
|
50 |
filter['subtree'] = [criteria] |
|
51 |
return filter |
Also available in: Unified diff