Reverse the relationship between __contains__ and has_key in all cache classes since...
authorZac Medico <zmedico@gentoo.org>
Thu, 26 Oct 2006 08:10:35 +0000 (08:10 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 Oct 2006 08:10:35 +0000 (08:10 -0000)
svn path=/main/trunk/; revision=4821

pym/cache/anydbm.py
pym/cache/flat_hash.py
pym/cache/flat_list.py
pym/cache/metadata_overlay.py
pym/cache/sql_template.py
pym/cache/sqlite.py
pym/cache/template.py

index 87e448f301410626c5eeb18f671e6aa7cc24a304..a4e0003d423f463d9220cae8946d49198f749b7b 100644 (file)
@@ -63,7 +63,7 @@ class database(fs_template.FsBased):
        def iterkeys(self):
                return iter(self.__db.keys())
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                return cpv in self.__db
 
        def __del__(self):
index d4c5930c74d8853ef31768b567ff7fd6d7293778..a8adb220515ec4af371db2159ff5e427833d0adf 100644 (file)
@@ -98,7 +98,7 @@ class database(fs_template.FsBased):
                                raise cache_errors.CacheCorruption(cpv, e)
 
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                return os.path.exists(os.path.join(self.location, cpv))
 
 
index 65fe5a781876a8ff20177ae52f554d14e886ee1a..85efa4c0214cc7ac56bfd44702be3b282cd126d2 100644 (file)
@@ -82,7 +82,7 @@ class database(fs_template.FsBased):
                                raise cache_errors.CacheCorruption(cpv, e)
 
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                return os.path.exists(os.path.join(self._base, cpv))
 
 
index 673ba8dff8c86b20cf1a93c8c77b2be36241ecc0..9320b0938b0648d6b6e220cb3367dcbf1565ec9e 100644 (file)
@@ -55,7 +55,7 @@ class database(template.database):
                else:
                        del self.db_rw[cpv]
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                try:
                        self[cpv] # validates whiteout when necessary
                except KeyError:
index 5c8af08f8d82324543c79fe524f08bce3b7e6f45..e635616e913d09ae2ef4b015924579bc01cbb0c6 100644 (file)
@@ -196,7 +196,7 @@ class SQLDatabase(template.database):
                return self.con.fetchone()[0]
 
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                if not self.autocommits:
                        try:    self.commit()
                        except self._BaseError, e:
index 571eff39b9509a386fb095bd8dd72e4df0616dda..6b1a3d32318dc3389029341e184d22981a334761 100644 (file)
@@ -200,7 +200,7 @@ class database(fs_template.FsBased):
                        self._db_table["packages"]["package_key"],
                        self._db_escape_string(cpv)))
 
-       def has_key(self, cpv):
+       def __contains__(self, cpv):
                cursor = self._db_cursor
                cursor.execute(" ".join(
                        ["SELECT %s FROM %s" %
index 565e7d2abe0c6190257a9c11220e009de7df41aa..a628b1161a0ad8304e5e204394609dc4b7cd62cb 100644 (file)
@@ -89,7 +89,7 @@ class database(object):
                raise NotImplementedError
 
        def has_key(self, cpv):
-               raise NotImplementedError
+               return cpv in self
 
        def keys(self):
                return tuple(self.iterkeys())
@@ -114,7 +114,7 @@ class database(object):
                        raise NotImplementedError
 
        def __contains__(self, cpv):
-               return self.has_key(cpv)
+               raise NotImplementedError
 
        def get(self, k, x=None):
                try: