For simplicity and consistency, always use a regular expression
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 14:07:48 +0000 (14:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 14:07:48 +0000 (14:07 -0000)
for category validation instead of using a list.

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

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

index 70176c6f725514c1fabc41ffdefcc359fcc27023..4b66b6125af171e4dc0262af80ea578f7a451710 100644 (file)
@@ -485,8 +485,10 @@ class portdbapi(dbapi):
        def cp_all(self):
                "returns a list of all keys in our tree"
                d = {}
-               for x in self.mysettings.categories:
-                       for oroot in self.porttrees:
+               for oroot in self.porttrees:
+                       for x in listdir(oroot, EmptyOnError=1, ignorecvs=1, dirsonly=1):
+                               if not self._category_re.match(x):
+                                       continue
                                for y in listdir(oroot+"/"+x, EmptyOnError=1, ignorecvs=1, dirsonly=1):
                                        d[x+"/"+y] = None
                l = d.keys()
@@ -513,10 +515,7 @@ class portdbapi(dbapi):
                                        self.xcache["match-all"][mycp] = cachelist
                                return cachelist[:]
                mysplit = mycp.split("/")
-               if self.mysettings.profile_path:
-                       invalid_category = mysplit[0] not in self._categories
-               else:
-                       invalid_category = not self._category_re.match(mysplit[0])
+               invalid_category = not self._category_re.match(mysplit[0])
                d={}
                if mytree:
                        mytrees = [mytree]
index 9c4d99277e2f2337e9614bf12a3386bb02bf5ff7..8af2bde5d8dd6d228e6a2340e01e67df38ca4062 100644 (file)
@@ -181,15 +181,9 @@ class vardbapi(dbapi):
                if settings is None:
                        from portage import settings
                self.settings = settings
-               if categories is None:
-                       categories = settings.categories
-               self.categories = categories[:]
-               # If it seems like the profiles directory is missing, don't
-               # trust the categories list and try to work without it so
-               # that we can install binary packages without a profile or
-               # a portage tree.
-               if not self.settings.profile_path:
-                       self.categories = None
+               # The categories list is now automatically generated
+               # from a regular expression.
+               self.categories = None
                if vartree is None:
                        from portage import db
                        vartree = db[root]["vartree"]
@@ -385,12 +379,9 @@ class vardbapi(dbapi):
        def cpv_all(self, use_cache=1):
                returnme = []
                basepath = os.path.join(self.root, VDB_PATH) + os.path.sep
-               categories = self.categories
-               if not categories:
-                       categories = [cat for cat in listdir(basepath, dirsonly=True) \
-                               if self._category_re.match(cat)]
-                       self.categories = categories
-               for x in categories:
+               for x in listdir(basepath, EmptyOnError=1, ignorecvs=1, dirsonly=1):
+                       if not self._category_re.match(x):
+                               continue
                        for y in listdir(basepath + x, EmptyOnError=1):
                                if y.startswith("."):
                                        continue