index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-08-08 23:32:19 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-09 15:36:05 -0500 |
commit | 9d3d647f0031edd31fc7442f9d2cd9729718e41c (patch) | |
tree | c730e1cb3631e849d6490113d0efe6054b4ba344 /test | |
parent | 5f38660be12c898e6ddef0d09b973d259d80c763 (diff) |
-rw-r--r-- | test/pacman/pmdb.py | 26 |
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py index 63a156ec..5195ec64 100644 --- a/test/pacman/pmdb.py +++ b/test/pacman/pmdb.py @@ -58,6 +58,8 @@ class pmdb(object): self.dbdir = os.path.join(root, util.PM_DBPATH, treename) self.dbfile = None self.is_local = True + self.read_dircache = None + self.read_pkgcache = {} else: self.dbdir = None self.dbfile = os.path.join(root, util.PM_SYNCDBPATH, treename + ".db") @@ -81,20 +83,24 @@ class pmdb(object): if not self.dbdir or not os.path.isdir(self.dbdir): return None - dbentry = "" - for roots, dirs, files in os.walk(self.dbdir): - for i in dirs: - [pkgname, pkgver, pkgrel] = i.rsplit("-", 2) - if pkgname == name: - dbentry = i - break - if not dbentry: + dbentry = None + if self.read_dircache is None: + self.read_dircache = os.listdir(self.dbdir) + for entry in self.read_dircache: + [pkgname, pkgver, pkgrel] = entry.rsplit("-", 2) + if pkgname == name: + dbentry = entry + break + if dbentry is None: return None - path = os.path.join(self.dbdir, dbentry) - [pkgname, pkgver, pkgrel] = dbentry.rsplit("-", 2) + if pkgname in self.read_pkgcache: + return self.read_pkgcache[pkgname] + pkg = pmpkg.pmpkg(pkgname, pkgver + "-" + pkgrel) + self.read_pkgcache[pkgname] = pkg + path = os.path.join(self.dbdir, dbentry) # desc filename = os.path.join(path, "desc") if not os.path.isfile(filename): |