Revision b2d60e49 ncclient/capabilities.py

b/ncclient/capabilities.py
12 12
# See the License for the specific language governing permissions and
13 13
# limitations under the License.
14 14

  
15
#_capability_map = {
16
#    "urn:liberouter:params:netconf:capability:power-control:1.0":
17
#        [":power-control", ":power-control:1.0"]
18
#}
19

  
20 15
def _abbreviate(uri):
21 16
    if uri.startswith("urn:ietf:params:netconf:"):
22 17
        splitted = uri.split(":")
23 18
        if ":capability:" in uri:
24
            return [ ":" + splitted[5], ":" + splitted[5] + ":" + splitted[6] ]
19
            name, version = splitted[5], splitted[6]
20
            return [ ":" + name, ":" + name + ":" + version ]
25 21
        elif ":base:" in uri:
26 22
            return [ ":base", ":base" + ":" + splitted[5] ]
27
    #elif uri in _capability_map:
28
    #    return _capability_map[uri]
29 23
    return []
30 24

  
31 25
def schemes(url_uri):
......
62 56
        return len(self._dict)
63 57

  
64 58
    def __iter__(self):
65
        return self._dict.keys().__iter__()
59
        return self._dict.iterkeys()
66 60

  
67 61
    def __repr__(self):
68 62
        return repr(self._dict.keys())
69 63

  
70
    def __list__(self):
71
        return self._dict.keys()
72

  
73 64
    def add(self, uri):
74 65
        "Add a capability."
75 66
        self._dict[uri] = _abbreviate(uri)
......
77 68
    def remove(self, uri):
78 69
        "Remove a capability."
79 70
        if key in self._dict:
80
            del self._dict[key]
81
    
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
71
            del self._dict[key]

Also available in: Unified diff