diff options
Diffstat (limited to 'pym/portage/cache/template.py')
-rw-r--r-- | pym/portage/cache/template.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py index 161b07f55..d5a07528c 100644 --- a/pym/portage/cache/template.py +++ b/pym/portage/cache/template.py @@ -95,7 +95,7 @@ class database(object): return tuple(self.iterkeys()) def iterkeys(self): - raise NotImplementedError + return iter(self) def iteritems(self): for x in self.iterkeys(): @@ -123,6 +123,16 @@ class database(object): raise NotImplementedError return self.has_key(cpv) + def __iter__(self): + """This method should always be overridden. It is provided only for + backward compatibility with modules that override iterkeys instead. It + will automatically raise a NotImplementedError if iterkeys has not been + overridden.""" + if self.iterkeys is database.iterkeys: + # prevent a possible recursive loop + raise NotImplementedError(self) + return self.iterkeys() + def get(self, k, x=None): try: return self[k] |