Merged from trunk -r15285:15292
authorFabian Groffen <grobian@gentoo.org>
Sun, 31 Jan 2010 09:43:08 +0000 (09:43 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 31 Jan 2010 09:43:08 +0000 (09:43 -0000)
   | 15286   | fix: python dbm module doesn't accept unicode as key         |
   | volkmar |                                                              |

   | 15287   | Define __slots__ in all classes.                             |
   | zmedico |                                                              |

   | 15288   | In config._expandLicenseToken(), make sure traversed_groups  |
   | zmedico | is only initialized when appropriate.                        |

   | 15289   | Fix concatenation of list + tuple in                         |
   | zmedico | Manifest._createManifestEntries().                           |

   | 15290   | Don't generate DeprecationWarning for portdbapi arguments.   |
   | zmedico | Wait until new portdbapi constructor is in stable portage    |
   |         | first.                                                       |

   | 15291   | fix flat_list cache backend looks like it was outdated wrt.  |
   | volkmar | template cache backend                                       |

   | 15292   | Show a DeprecationWarning if the deprecated pordbapi         |
   | zmedico | constructor parameter is used incorrectly.                   |

svn path=/main/branches/prefix/; revision=15301

pym/portage/__init__.py
pym/portage/cache/anydbm.py
pym/portage/cache/flat_list.py
pym/portage/cache/mappings.py
pym/portage/dbapi/porttree.py
pym/portage/manifest.py

index 911714909b95ea8ca675e5fe0fc209718397a312..c442a116890413a8417f1e76165e74daa8a4baae 100644 (file)
@@ -2314,7 +2314,7 @@ class config(object):
                        rValue.append(token)
                        return rValue
                group_name = license_name[1:]
-               if not traversed_groups:
+               if traversed_groups is None:
                        traversed_groups = set()
                license_group = self._license_groups.get(group_name)
                if group_name in traversed_groups:
index 6add2da60c7c7448d9185f535bc0dc7edf8d17f2..33cedebbb1f028f7a7c8d6af7eae6b0244b11708 100644 (file)
@@ -63,10 +63,10 @@ class database(fs_template.FsBased):
 
        def _getitem(self, cpv):
                # we override getitem because it's just a cpickling of the data handed in.
-               return pickle.loads(self.__db[cpv])
+               return pickle.loads(self.__db[_unicode_encode(cpv)])
 
        def _setitem(self, cpv, values):
-               self.__db[cpv] = pickle.dumps(values,pickle.HIGHEST_PROTOCOL)
+               self.__db[_unicode_encode(cpv)] = pickle.dumps(values,pickle.HIGHEST_PROTOCOL)
 
        def _delitem(self, cpv):
                del self.__db[cpv]
index 51231a52a500e1108688500f850f2e7c4263a2f0..1c4ec68defa82d0bfb00955f658c3b64ff8e716d 100644 (file)
@@ -22,21 +22,21 @@ class database(fs_template.FsBased):
                'KEYWORDS',  'IUSE', 'UNUSED_00',
                'PDEPEND',   'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES')
 
-       def __init__(self, label, auxdbkeys, **config):
-               super(database,self).__init__(label, auxdbkeys, **config)
-               self._base = os.path.join(self._base, 
+       def __init__(self, *args, **config):
+               super(database,self).__init__(*args, **config)
+               self.location = os.path.join(self.location, 
                        self.label.lstrip(os.path.sep).rstrip(os.path.sep))
 
                if len(self._known_keys) > len(self.auxdbkey_order) + 2:
                        raise Exception("less ordered keys then auxdbkeys")
-               if not os.path.exists(self._base):
+               if not os.path.exists(self.location):
                        self._ensure_dirs()
 
 
        def _getitem(self, cpv):
                d = {}
                try:
-                       myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv),
+                       myf = codecs.open(_unicode_encode(os.path.join(self.location, cpv),
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['repo.content'],
                                errors='replace')
@@ -58,7 +58,7 @@ class database(fs_template.FsBased):
 
        def _setitem(self, cpv, values):
                s = cpv.rfind("/")
-               fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
+               fp=os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
                try:
                        myf = codecs.open(_unicode_encode(fp,
                                encoding=_encodings['fs'], errors='strict'),
@@ -84,7 +84,7 @@ class database(fs_template.FsBased):
                myf.close()
                self._ensure_access(fp, mtime=values["_mtime_"])
                #update written.  now we move it.
-               new_fp = os.path.join(self._base,cpv)
+               new_fp = os.path.join(self.location,cpv)
                try:
                        os.rename(fp, new_fp)
                except (OSError, IOError) as e:
@@ -94,7 +94,7 @@ class database(fs_template.FsBased):
 
        def _delitem(self, cpv):
                try:
-                       os.remove(os.path.join(self._base,cpv))
+                       os.remove(os.path.join(self.location,cpv))
                except OSError as e:
                        if errno.ENOENT == e.errno:
                                raise KeyError(cpv)
@@ -103,13 +103,13 @@ class database(fs_template.FsBased):
 
 
        def __contains__(self, cpv):
-               return os.path.exists(os.path.join(self._base, cpv))
+               return os.path.exists(os.path.join(self.location, cpv))
 
 
        def __iter__(self):
                """generator for walking the dir struct"""
-               dirs = [self._base]
-               len_base = len(self._base)
+               dirs = [self.location]
+               len_base = len(self.location)
                while len(dirs):
                        for l in os.listdir(dirs[0]):
                                if l.endswith(".cpickle"):
index 2e24a7a8a0a309cf6d5e2bc0fe8e29120b132736..f15f362b0d8608b85c22cae8884172d5be0cb08b 100644 (file)
@@ -22,6 +22,8 @@ class Mapping(object):
        for UserDict.DictMixin so that code converted via 2to3 will run.
        """
 
+       __slots__ = ()
+
        def __iter__(self):
                return iter(self.keys())
 
@@ -79,6 +81,8 @@ class MutableMapping(Mapping):
        A mutable vesion of the Mapping class.
        """
 
+       __slots__ = ()
+
        def clear(self):
                for key in list(self):
                        del self[key]
@@ -146,6 +150,8 @@ class UserDict(MutableMapping):
             http://bugs.python.org/issue2876
        """
 
+       __slots__ = ('data',)
+
        def __init__(self, *args, **kwargs):
 
                self.data = {}
@@ -190,6 +196,8 @@ class UserDict(MutableMapping):
 
 class OrderedDict(UserDict):
 
+       __slots__ = ('_order',)
+
        def __init__(self, *args, **kwargs):
                self._order = []
                UserDict.__init__(self, *args, **kwargs)
index 1b5567a8e003b4954a83db86590b22f6c9f7124d..d5ecce987619c85c385d528a2175f885130864ed 100644 (file)
@@ -143,7 +143,7 @@ class portdbapi(dbapi):
 
        def __init__(self, _unused_param=None, mysettings=None):
                """
-               @param _unused_param: deprecated
+               @param _unused_param: deprecated, use mysettings['PORTDIR'] instead
                @type _unused_param: None
                @param mysettings: an immutable config instance
                @type mysettings: portage.config
@@ -157,15 +157,17 @@ class portdbapi(dbapi):
                        from portage import settings
                        self.mysettings = config(clone=settings)
 
-               if _unused_param is not None:
+               porttree_root = self.mysettings['PORTDIR']
+
+               # always show this warning after this parameter
+               # is unused in stable portage
+               if _unused_param is not None and _unused_param != porttree_root:
                        warnings.warn("The first parameter of the " + \
                                "portage.dbapi.porttree.portdbapi" + \
                                " constructor is now unused. Use " + \
                                "mysettings['PORTDIR'] instead.",
                                DeprecationWarning)
 
-               porttree_root = self.mysettings['PORTDIR']
-
                # This is strictly for use in aux_get() doebuild calls when metadata
                # is generated by the depend phase.  It's safest to use a clone for
                # this purpose because doebuild makes many changes to the config
index fc8afb4cf5bcfda8bcd3334910f08f7b70c1c82b..470f732d6850278d179f6b884f6c2b6861a3e3d7 100644 (file)
@@ -205,6 +205,8 @@ class Manifest(object):
                return myhashdict
 
        def _createManifestEntries(self):
+               valid_hashes = set(portage.const.MANIFEST2_HASH_FUNCTIONS)
+               valid_hashes.add('size')
                mytypes = list(self.fhashdict)
                mytypes.sort()
                for t in mytypes:
@@ -213,10 +215,8 @@ class Manifest(object):
                        for f in myfiles:
                                myentry = Manifest2Entry(
                                        type=t, name=f, hashes=self.fhashdict[t][f].copy())
-                               myhashkeys = list(myentry.hashes)
-                               myhashkeys.sort()
-                               for h in myhashkeys:
-                                       if h not in ["size"] + portage.const.MANIFEST2_HASH_FUNCTIONS:
+                               for h in list(myentry.hashes):
+                                       if h not in valid_hashes:
                                                del myentry.hashes[h]
                                yield myentry