* In vardbapi.cpv_all() use catpkgsplit() for validation since that's what
authorZac Medico <zmedico@gentoo.org>
Mon, 5 May 2008 18:40:49 +0000 (18:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 5 May 2008 18:40:49 +0000 (18:40 -0000)
  with cp_all() uses.
* Use the listdir() dirsonly=1 parameter to avoid unnecessary stat calls
  via os.path.isdir().

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

pym/portage/dbapi/vartree.py

index b12a1993a6d068f5108231c9b9754278047ac903..34b8def7b9502bed5274677dc7545e2aba02bb7b 100644 (file)
@@ -460,13 +460,19 @@ class vardbapi(dbapi):
                                continue
                        if not self._category_re.match(x):
                                continue
-                       for y in listdir(basepath + x, EmptyOnError=1):
+                       for y in listdir(basepath + x, EmptyOnError=1, dirsonly=1):
                                if self._excluded_dirs.match(y) is not None:
                                        continue
                                subpath = x + "/" + y
                                # -MERGING- should never be a cpv, nor should files.
-                               if os.path.isdir(basepath + subpath) and (pkgsplit(y) is not None):
-                                       returnme += [subpath]
+                               try:
+                                       if catpkgsplit(subpath) is None:
+                                               self.invalidentry(os.path.join(self.root, subpath))
+                                               continue
+                               except portage.exception.InvalidData:
+                                       self.invalidentry(os.path.join(self.root, subpath))
+                                       continue
+                               returnme.append(subpath)
                return returnme
 
        def cp_all(self, use_cache=1):