For python-3.0 compatibility, make dict-like classes modify their keys(),
authorZac Medico <zmedico@gentoo.org>
Wed, 4 Feb 2009 23:30:42 +0000 (23:30 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 4 Feb 2009 23:30:42 +0000 (23:30 -0000)
items(), and values() methods appropriatly for the current python version.

svn path=/main/trunk/; revision=12584

pym/portage/__init__.py
pym/portage/cache/anydbm.py
pym/portage/cache/mappings.py
pym/portage/cache/sql_template.py
pym/portage/cache/template.py

index cf0f35b136aa68519295dc180794b7b36b2bfb1e..85c970440d9dad8ced9d18d266ac5314f277d8a4 100644 (file)
@@ -2983,6 +2983,10 @@ class config(object):
                                        pass
                return self._selinux_enabled
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+               items = iteritems
+
 def _shell_quote(s):
        """
        Quote a string in double-quotes and use backslashes to
index 47b8ac1bd4740305bd25788b0a18ff4931469227..9007a1a5679d34cba3a1f5b7142a3c8948d0a9b0 100644 (file)
@@ -9,6 +9,7 @@ try:
 except ImportError:
        import pickle
 import os
+import sys
 from portage.cache import fs_template
 from portage.cache import cache_errors
 
@@ -70,3 +71,6 @@ class database(fs_template.FsBased):
                if "__db" in self.__dict__ and self.__db != None:
                        self.__db.sync()
                        self.__db.close()
+
+       if sys.hexversion >= 0x3000000:
+               items = iteritems
index 112301476fcc55c31fcddce0d48d3d0357ed6ab2..010eb7f8e8d8b19bad1477acf365ecdcebeb693e 100644 (file)
@@ -3,6 +3,7 @@
 # License: GPL2
 # $Id$
 
+import sys
 import UserDict
 import warnings
 import weakref
@@ -65,6 +66,10 @@ class ProtectedDict(UserDict.DictMixin):
                        DeprecationWarning)
                return key in self
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+               items = iteritems
+
 class LazyLoad(UserDict.DictMixin):
        """
        Lazy loading of values for a dict
@@ -111,6 +116,10 @@ class LazyLoad(UserDict.DictMixin):
                        self.pull = None
                return key in self.d
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+               items = iteritems
+
 _slot_dict_classes = weakref.WeakValueDictionary()
 
 def slot_dict_class(keys, prefix="_val_"):
@@ -265,6 +274,11 @@ def slot_dict_class(keys, prefix="_val_"):
                        def __str__(self):
                                return str(dict(self.iteritems()))
 
+                       if sys.hexversion >= 0x3000000:
+                               items = iteritems
+                               keys = __iter__
+                               values = itervalues
+
                v = SlotDict
                _slot_dict_classes[v.allowed_keys] = v
        return v
index fe873c3eab4dad2def53b3d6a4cae2b6157e2a94..e5903cd67382ace9be3e2b6167d0a5f3ef3c5c6c 100644 (file)
@@ -3,6 +3,7 @@
 # License: GPL2
 # $Id$
 
+import sys
 from portage.cache import template, cache_errors
 from portage.cache.template import reconstruct_eclasses
 
@@ -277,3 +278,5 @@ class SQLDatabase(template.database):
 
                return [ row[0] for row in self.con.fetchall() ]
 
+       if sys.hexversion >= 0x3000000:
+               items = iteritems
index 238f9dc40c40f7c7003b7251b12b05283aa4b577..35b9efeffbd976b7eaddb908433e8fb0126af4df 100644 (file)
@@ -6,6 +6,7 @@
 from portage.cache import cache_errors
 from portage.cache.cache_errors import InvalidRestriction
 from portage.cache.mappings import ProtectedDict
+import sys
 import warnings
 
 class database(object):
@@ -177,6 +178,9 @@ class database(object):
                        if cont:
                                yield cpv
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+               items = iteritems
 
 def serialize_eclasses(eclass_dict):
        """takes a dict, returns a string representing said dict"""