Implement _getitem instead of __getitem__ so that the base class __getitem__
authorZac Medico <zmedico@gentoo.org>
Sun, 8 Mar 2009 05:25:18 +0000 (05:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Mar 2009 05:25:18 +0000 (05:25 -0000)
implementation is used for _mtime_ and _eclasses_ handling.

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

pym/portage/cache/flat_hash.py
pym/portage/cache/metadata.py

index f6bf6d078e774b72563c122e6753f953f3dc89d1..ac1b7f190e055d6a7b527199147ca9acd6feb543 100644 (file)
@@ -23,26 +23,16 @@ class database(fs_template.FsBased):
                if not self.readonly and not os.path.exists(self.location):
                        self._ensure_dirs()
 
-       def __getitem__(self, cpv):
+       def _getitem(self, cpv):
                fp = os.path.join(self.location, cpv)
                try:
                        myf = open(fp, "r")
                        try:
                                d = self._parse_data(myf, cpv)
-                               if "_mtime_" not in d:
-                                       """Backward compatibility with old cache that uses mtime
-                                       mangling."""
-                                       d["_mtime_"] = long(os.fstat(myf.fileno()).st_mtime)
-                               mtime = d.get('_mtime_')
-                               if mtime is None:
-                                       raise cache_errors.CacheCorruption(cpv,
-                                               '_mtime_ field is missing')
-                               try:
-                                       mtime = long(mtime)
-                               except ValueError:
-                                       raise cache_errors.CacheCorruption(cpv,
-                                               '_mtime_ conversion to long failed: %s' % (mtime,))
-                               d['_mtime_'] = mtime
+                               if '_mtime_' not in d:
+                                       # Backward compatibility with old cache
+                                       # that uses mtime mangling.
+                                       d['_mtime_'] = long(os.fstat(myf.fileno()).st_mtime)
                                return d
                        finally:
                                myf.close()
@@ -57,10 +47,6 @@ class database(fs_template.FsBased):
                except ValueError, e:
                        # If a line is missing an "=", the split length is 1 instead of 2.
                        raise cache_errors.CacheCorruption(cpv, e)
-               if "_eclasses_" in d:
-                       d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
-               else:
-                       d["_eclasses_"] = {}
                return d
 
        def _setitem(self, cpv, values):
index 22cf51e56c82e729bb02910354ec8258e6d055a8..4f74b767d1f168170a6682c046c5eb4916d15bc1 100644 (file)
@@ -21,6 +21,7 @@ class database(flat_hash.database):
                'PDEPEND',   'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES')
 
        autocommits = True
+       serialize_eclasses = False
 
        _hashed_re = re.compile('^(\\w+)=([^\n]*)')
 
@@ -30,10 +31,6 @@ class database(flat_hash.database):
                self.location = os.path.join(loc, "metadata","cache")
                self.ec = portage.eclass_cache.cache(loc)
 
-       def __getitem__(self, cpv):
-               return flat_hash.database.__getitem__(self, cpv)
-
-
        def _parse_data(self, data, cpv):
                _hashed_re_match = self._hashed_re.match
                data = list(data)