summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-31 05:50:15 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-31 05:50:15 +0000
commit40ccd9c85f187078d6e0f69ab664853ead31ba3d (patch)
tree1d44d06886f0b0b34f64f751dc60fee6c28d4e45
parent8e10426aad390c88b3683b374199a20b48cdce9e (diff)
downloadportage-40ccd9c85f187078d6e0f69ab664853ead31ba3d.tar.gz
portage-40ccd9c85f187078d6e0f69ab664853ead31ba3d.tar.bz2
portage-40ccd9c85f187078d6e0f69ab664853ead31ba3d.zip
Add a "consumer" keyword parameter to the MetadataRegen constructor which
can be used to pass in a callback that is called for each ebuild that is processed (allowing access to the ebuild metadata). svn path=/main/trunk/; revision=13256
-rw-r--r--pym/_emerge/__init__.py34
-rw-r--r--pym/portage/dbapi/porttree.py1
2 files changed, 27 insertions, 8 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 611ac064c..e325f1f25 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -3024,7 +3024,7 @@ class EbuildMetadataPhase(SubProcess):
"""
__slots__ = ("cpv", "ebuild_path", "fd_pipes", "metadata_callback",
- "ebuild_mtime", "portdb", "repo_path", "settings") + \
+ "ebuild_mtime", "metadata", "portdb", "repo_path", "settings") + \
("_raw_metadata",)
_file_names = ("ebuild",)
@@ -3129,8 +3129,9 @@ class EbuildMetadataPhase(SubProcess):
self.returncode = 1
else:
metadata = izip(portage.auxdbkeys, metadata_lines)
- self.metadata_callback(self.cpv, self.ebuild_path,
- self.repo_path, metadata, self.ebuild_mtime)
+ self.metadata = self.metadata_callback(self.cpv,
+ self.ebuild_path, self.repo_path, metadata,
+ self.ebuild_mtime)
class EbuildProcess(SpawnProcess):
@@ -11573,7 +11574,8 @@ class Scheduler(PollScheduler):
class MetadataRegen(PollScheduler):
- def __init__(self, portdb, cp_iter=None, max_jobs=None, max_load=None):
+ def __init__(self, portdb, cp_iter=None, consumer=None,
+ max_jobs=None, max_load=None):
PollScheduler.__init__(self)
self._portdb = portdb
self._global_cleanse = False
@@ -11583,6 +11585,7 @@ class MetadataRegen(PollScheduler):
# iterate over every single cp.
self._global_cleanse = True
self._cp_iter = cp_iter
+ self._consumer = consumer
if max_jobs is None:
max_jobs = 1
@@ -11613,6 +11616,7 @@ class MetadataRegen(PollScheduler):
portdb = self._portdb
valid_pkgs = self._valid_pkgs
cp_set = self._cp_set
+ consumer = self._consumer
for cp in self._cp_iter:
cp_set.add(cp)
@@ -11621,11 +11625,19 @@ class MetadataRegen(PollScheduler):
for cpv in cpv_list:
valid_pkgs.add(cpv)
ebuild_path, repo_path = portdb.findname2(cpv)
- metadata_process = portdb._metadata_process(
+ metadata, st, emtime = portdb._pull_valid_cache(
cpv, ebuild_path, repo_path)
- if metadata_process is None:
+ if metadata is not None:
+ if consumer is not None:
+ consumer(cpv, ebuild_path,
+ repo_path, metadata)
continue
- yield metadata_process
+
+ yield EbuildMetadataPhase(cpv=cpv, ebuild_path=ebuild_path,
+ ebuild_mtime=emtime,
+ metadata_callback=portdb._metadata_callback,
+ portdb=portdb, repo_path=repo_path,
+ settings=portdb.doebuild_settings)
def run(self):
@@ -11700,7 +11712,13 @@ class MetadataRegen(PollScheduler):
def _metadata_exit(self, metadata_process):
self._jobs -= 1
- if metadata_process.returncode != os.EX_OK:
+ if metadata_process.returncode == os.EX_OK:
+ if self._consumer is not None:
+ self._consumer(metadata_process.cpv,
+ metadata_process.ebuild_path,
+ metadata_process.repo_path,
+ metadata_process.metadata)
+ else:
self.returncode = 1
self._error_count += 1
self._valid_pkgs.discard(metadata_process.cpv)
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index c94a2965d..9d4b1523d 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -349,6 +349,7 @@ class portdbapi(dbapi):
metadata["EAPI"] = "-" + eapi.lstrip("-")
self.auxdb[repo_path][cpv] = metadata
+ return metadata
def _pull_valid_cache(self, cpv, ebuild_path, repo_path):