* Initialize dbapi._categories = None so that we can compare
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Dec 2007 09:58:56 +0000 (09:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Dec 2007 09:58:56 +0000 (09:58 -0000)
with None instead of using hasattr.
* Remove unwanted self._categories initialization from the
  portdbapi constructor.

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

pym/portage/dbapi/__init__.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/dbapi/virtual.py

index d41a7fba3ee106b41fcee53b4b8e8eaa3f41eefa..cd3208d504e3a5668c7dab784076c60b57a53f94 100644 (file)
@@ -15,6 +15,7 @@ from portage.versions import catpkgsplit, catsplit, pkgcmp
 class dbapi(object):
        _category_re = re.compile(r'^\w[-.+\w]*$')
        _pkg_dir_name_re = re.compile(r'^\w[-+\w]*$')
+       _categories = None
        def __init__(self):
                pass
 
@@ -25,7 +26,7 @@ class dbapi(object):
                can delete the self._categories attribute in cases when the cached
                categories become invalid and need to be regenerated.
                """
-               if hasattr(self, "_categories"):
+               if self._categories is not None:
                        return self._categories
                categories = set()
                cat_pattern = re.compile(r'(.*)/.*')
index 7ce65b998363b4a64d64a0865a3189e1e9a4adab..61ce3c47bc1b95c48c3f924b79bd21cc32f1099c 100644 (file)
@@ -39,7 +39,6 @@ class portdbapi(dbapi):
                else:
                        from portage import settings
                        self.mysettings = config(clone=settings)
-               self._categories = set(self.mysettings.categories)
                # 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 bfed2f79882eb72e7346be19b477b5232e31b9a2..15c2586ea8783e4c070b5ea599a20a0eba4a6b14 100644 (file)
@@ -1073,8 +1073,8 @@ class dblink(object):
                The caller must ensure that lockdb() and unlockdb() are called
                before and after this method.
                """
-               if hasattr(self.vartree.dbapi, "_categories"):
-                       del self.vartree.dbapi._categories
+               if self.vartree.dbapi._categories is not None:
+                       self.vartree.dbapi._categories = None
                # When others_in_slot is supplied, the security check has already been
                # done for this slot, so it shouldn't be repeated until the next
                # replacement or unmerge operation.
@@ -2428,8 +2428,8 @@ class dblink(object):
                we won't be able to later if they get unmerged (happens
                when namespace changes).
                """
-               if hasattr(self.vartree.dbapi, "_categories"):
-                       del self.vartree.dbapi._categories
+               if self.vartree.dbapi._categories is not None:
+                       self.vartree.dbapi._categories = None
                if self.myroot == "/" and \
                        "sys-apps" == self.cat and \
                        "portage" == pkgsplit(self.pkg)[0] and \
index 3d5472f1e8fbce749b88e9b0827cc720734cf413..444b5363a0e0c3ef91d707b12c11166a2ce5d4a8 100644 (file)
@@ -26,8 +26,8 @@ class fakedbapi(dbapi):
                self._match_cache = {}
 
        def _clear_cache(self):
-               if hasattr(self, "_categories"):
-                       del self._categories
+               if self._categories is not None:
+                       self._categories = None
                if self._match_cache:
                        self._match_cache = {}