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

svn path=/main/branches/2.1.2/; revision=9093

pym/portage.py

index cbf3496b04b5e78e324cc13f1af117716424a9c3..4524c049b1245b9ed3867932f88a0965e5e360dc 100644 (file)
@@ -5811,6 +5811,7 @@ class portagetree:
 class dbapi:
        _category_re = re.compile(r'^\w[-.+\w]*$')
        _pkg_dir_name_re = re.compile(r'^\w[-+\w]*$')
+       _categories = None
        def __init__(self):
                pass
 
@@ -5821,7 +5822,7 @@ class dbapi:
                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'(.*)/.*')
@@ -5947,8 +5948,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 = {}
 
@@ -6774,7 +6775,6 @@ class portdbapi(dbapi):
                else:
                        global 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
@@ -8167,8 +8167,8 @@ class dblink:
                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.
@@ -9396,8 +9396,8 @@ class dblink:
                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 \