From: Michael Tremer Date: Sun, 17 Jul 2011 15:38:55 +0000 (+0200) Subject: Fix reading the "build" repository and give it a shiny progress bar. X-Git-Tag: 0.9.3~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=898278a246db8f0bcfd1c28b32070a1b4933f5bc;p=pakfire.git Fix reading the "build" repository and give it a shiny progress bar. --- diff --git a/pakfire/repository/index.py b/pakfire/repository/index.py index 75949d18f..4714ad107 100644 --- a/pakfire/repository/index.py +++ b/pakfire/repository/index.py @@ -246,14 +246,33 @@ class IndexDir(Index): self.collect_packages(self.path) def collect_packages(self, path): - # XXX make progress bar for that - for dir, subdirs, files in os.walk(path): - for file in sorted(files): + logging.debug("Collecting all packages from %s" % path) + pkgs = [] + + # Get a filelist of all files that could possibly be packages. + files = [] + for dir, subdirs, _files in os.walk(path): + for file in sorted(_files): # Skip files that do not have the right extension if not file.endswith(".%s" % PACKAGE_EXTENSION): continue - package = packages.open(self.pakfire, self.repo, os.path.join(dir, file)) + file = os.path.join(dir, file) + files.append(file) + + if not files: + return pkgs + + # Create progress bar. + pb = util.make_progress(_("Loading from %s") % path, len(files)) + i = 0 + + for file in files: + if pb: + i += 1 + pb.update(i) + + package = packages.open(self.pakfire, self.repo, file) if isinstance(package, packages.BinaryPackage): if not package.arch in (self.repo.arch, "noarch"): @@ -267,8 +286,12 @@ class IndexDir(Index): continue self.add_package(package) + pkgs.append(package) + + if pb: + pb.finish() - yield package + return pkgs class IndexLocal(Index):