Revision 4bc8021f ncclient/capabilities.py
b/ncclient/capabilities.py | ||
---|---|---|
29 | 29 |
return [] |
30 | 30 |
|
31 | 31 |
def schemes(url_uri): |
32 |
"""Given a URI that has a *scheme* query string (i.e. *:url* capability |
|
33 |
URI), will return a list of supported schemes.
|
|
32 |
"""Given a URI that has a *scheme* query string (i.e. *:url* capability URI), will return a list
|
|
33 |
of supported schemes. |
|
34 | 34 |
""" |
35 | 35 |
return url_uri.partition("?scheme=")[2].split(",") |
36 | 36 |
|
37 | 37 |
class Capabilities: |
38 | 38 |
|
39 |
"""Represents the set of capabilities available to a NETCONF client or |
|
40 |
server.
|
|
39 |
"""Represents the set of capabilities available to a NETCONF client or server. It is initialized
|
|
40 |
with a list of capability URI's. These can be iterated over.
|
|
41 | 41 |
|
42 |
Presence of a capability can be checked with the *in* operation. In addition |
|
43 |
to the URI, for capabilities of the form |
|
44 |
*urn:ietf:params:netconf:capability:$name:$version* their shorthand can be |
|
45 |
used as a key. For example, for |
|
46 |
*urn:ietf:params:netconf:capability:candidate:1.0* the shorthand would be |
|
47 |
*:candidate*. If version is significant, use *:candidate:1.0* as key. |
|
42 |
Presence of a capability can be checked with the *in* operation. In addition to the URI, for |
|
43 |
capabilities of the form *urn:ietf:params:netconf:capability:$name:$version* their shorthand can |
|
44 |
be used as a key. For example, for *urn:ietf:params:netconf:capability:candidate:1.0* the |
|
45 |
shorthand would be *:candidate*. If version is significant, use *:candidate:1.0* as key. |
|
48 | 46 |
""" |
49 | 47 |
|
50 | 48 |
def __init__(self, capabilities): |
51 |
"Initializes with a list of capability URI's" |
|
52 | 49 |
self._dict = {} |
53 | 50 |
for uri in capabilities: |
54 | 51 |
self._dict[uri] = _abbreviate(uri) |
... | ... | |
74 | 71 |
return self._dict.keys() |
75 | 72 |
|
76 | 73 |
def add(self, uri): |
77 |
"Add a capability" |
|
74 |
"Add a capability."
|
|
78 | 75 |
self._dict[uri] = _abbreviate(uri) |
79 | 76 |
|
80 | 77 |
def remove(self, uri): |
81 |
"Remove a capability" |
|
78 |
"Remove a capability."
|
|
82 | 79 |
if key in self._dict: |
83 | 80 |
del self._dict[key] |
84 | 81 |
|
85 |
def get_uri(self, shorthand): |
|
86 |
for uri, abbrs in self._dict.items(): |
|
87 |
if shorthand in abbrs: |
|
88 |
return uri |
|
82 |
#def get_uri(self, shorthand): |
|
83 |
# "Returns the URI that is inferred for a given shorthand." |
|
84 |
# for uri, abbrs in self._dict.items(): |
|
85 |
# if shorthand in abbrs: |
|
86 |
# return uri |
Also available in: Unified diff