Mercurial > public > mercurial-scm > hg
comparison mercurial/namespaces.py @ 23761:19d6271a70db
namespaces: add __iter__ and iteritems methods
Iterating over all the namespaces is a common operation, naturally, so we add
those methods now. Since we are using a sorted dictionary, this method just
calls the underlying __iter__ or iteritems method.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 22 Dec 2014 09:07:37 -0800 |
parents | 50229b4c33be |
children | b9537ee87961 |
comparison
equal
deleted
inserted
replaced
23760:50229b4c33be | 23761:19d6271a70db |
---|---|
46 self.addnamespace(n) | 46 self.addnamespace(n) |
47 | 47 |
48 def __getitem__(self, namespace): | 48 def __getitem__(self, namespace): |
49 """returns the namespace object""" | 49 """returns the namespace object""" |
50 return self._names[namespace] | 50 return self._names[namespace] |
51 | |
52 def __iter__(self): | |
53 return self._names.__iter__() | |
54 | |
55 def iteritems(self): | |
56 return self._names.iteritems() | |
51 | 57 |
52 def addnamespace(self, namespace, order=None): | 58 def addnamespace(self, namespace, order=None): |
53 """register a namespace | 59 """register a namespace |
54 | 60 |
55 namespace: the name to be registered (in plural form) | 61 namespace: the name to be registered (in plural form) |