summaryrefslogtreecommitdiffstats
path: root/bin/emaint
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-05-27 02:10:23 +0000
committerZac Medico <zmedico@gentoo.org>2007-05-27 02:10:23 +0000
commit02417974e952f0c26e1a1c24ec42204be22bc1a2 (patch)
tree17f8e325e092e5ff9d924057031bc0ba60c675e7 /bin/emaint
parentb512418b32c40272a05f332b4d7596acb0c24976 (diff)
downloadportage-02417974e952f0c26e1a1c24ec42204be22bc1a2.tar.gz
portage-02417974e952f0c26e1a1c24ec42204be22bc1a2.tar.bz2
portage-02417974e952f0c26e1a1c24ec42204be22bc1a2.zip
In the WorldHandler class, add support for an onProgress callback that can be used notify the user of job progress. This isn't really useful for WorldHandler since it completes quickly, but it will be useful for longer running tasks.
svn path=/main/trunk/; revision=6637
Diffstat (limited to 'bin/emaint')
-rwxr-xr-xbin/emaint17
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/emaint b/bin/emaint
index d91734833..0e9ba853d 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -27,13 +27,20 @@ class WorldHandler(object):
self.world_file = os.path.join("/", portage.const.WORLD_FILE)
self.found = os.access(self.world_file, os.R_OK)
+ def _check_world(self, onProgress):
categories = set(portage.settings.categories)
myroot = portage.settings["ROOT"]
vardb = portage.db[myroot]["vartree"].dbapi
- for atom in open(self.world_file).read().split():
+ world_atoms = open(self.world_file).read().split()
+ maxval = len(world_atoms)
+ if onProgress:
+ onProgress(maxval, 0)
+ for i, atom in enumerate(world_atoms):
if not portage.isvalidatom(atom):
self.invalid.append(atom)
+ if onProgress:
+ onProgress(maxval, i+1)
continue
okay = True
if not vardb.match(atom):
@@ -44,8 +51,11 @@ class WorldHandler(object):
okay = False
if okay:
self.okay.append(atom)
+ if onProgress:
+ onProgress(maxval, i+1)
- def check(self):
+ def check(self, onProgress=None):
+ self._check_world(onProgress)
errors = []
if self.found:
errors += map(lambda x: "'%s' is not a valid atom" % x, self.invalid)
@@ -55,7 +65,8 @@ class WorldHandler(object):
errors.append(self.world_file + " could not be opened for reading")
return errors
- def fix(self):
+ def fix(self, onProgress=None):
+ self._check_world(onProgress)
errors = []
try:
portage.write_atomic(self.world_file, "\n".join(self.okay))