diff options
Diffstat (limited to 'pym/portage/dbapi/__init__.py')
-rw-r--r-- | pym/portage/dbapi/__init__.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index b4ec89e53..fce395b00 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -53,3 +53,28 @@ class dbapi(object): else: writemsg("!!! Invalid db entry: %s\n" % mypath, noiselevel=-1) + def update_ents(self, updates, onProgress=None): + """ + Update metadata of all packages for packages moves. + @param updates: A list of move commands + @type updates: List + @param onProgress: A progress callback function + @type onProgress: a callable that takes 2 integer arguments: maxval and curval + """ + cpv_all = self.cpv_all() + cpv_all.sort() + maxval = len(cpv_all) + aux_get = self.aux_get + aux_update = self.aux_update + update_keys = ["DEPEND", "RDEPEND", "PDEPEND", "PROVIDE"] + from itertools import izip + from portage.update import update_dbentries + if onProgress: + onProgress(maxval, 0) + for i, cpv in enumerate(cpv_all): + metadata = dict(izip(update_keys, aux_get(cpv, update_keys))) + metadata_updates = update_dbentries(updates, metadata) + if metadata_updates: + aux_update(cpv, metadata_updates) + if onProgress: + onProgress(maxval, i+1) |