From: Zac Medico Date: Mon, 6 Jun 2011 09:11:31 +0000 (-0700) Subject: getmaskingreason: add myrepo argument X-Git-Tag: v2.2.0_alpha38~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=29dc8a7795161bd37e9cfbb5e2b19ee2c34f7a02;p=portage.git getmaskingreason: add myrepo argument --- diff --git a/pym/portage/package/ebuild/getmaskingreason.py b/pym/portage/package/ebuild/getmaskingreason.py index 6a0cf424c..4e3833d03 100644 --- a/pym/portage/package/ebuild/getmaskingreason.py +++ b/pym/portage/package/ebuild/getmaskingreason.py @@ -1,4 +1,4 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = ['getmaskingreason'] @@ -9,10 +9,13 @@ from portage.const import USER_CONFIG_PATH from portage.dep import Atom, match_from_list, _slot_separator, _repo_separator from portage.exception import InvalidAtom from portage.localization import _ +from portage.repository.config import _gen_valid_repo from portage.util import grablines, normalize_path from portage.versions import catpkgsplit +from _emerge.Package import Package -def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False): +def getmaskingreason(mycpv, metadata=None, settings=None, + portdb=None, return_location=False, myrepo=None): if settings is None: settings = portage.settings if portdb is None: @@ -20,21 +23,37 @@ def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_lo mysplit = catpkgsplit(mycpv) if not mysplit: raise ValueError(_("invalid CPV: %s") % mycpv) + + if myrepo: + myrepo = _gen_valid_repo(myrepo) + if metadata is None: db_keys = list(portdb._aux_cache_keys) try: - metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) + metadata = dict(zip(db_keys, + portdb.aux_get(mycpv, db_keys, myrepo=myrepo))) except KeyError: if not portdb.cpv_exists(mycpv): raise - if metadata is None: - # Can't access SLOT due to corruption. - cpv_slot_list = [mycpv] - else: + else: + if not myrepo: + myrepo = _gen_valid_repo(metadata["repository"]) + + elif not myrepo: + myrepo = metadata.get("repository") + if myrepo is not None: + myrepo = _gen_valid_repo(metadata["repository"]) + + # Sometimes we can't access SLOT or repository due to corruption. + pkg = mycpv + if metadata is not None: pkg = "".join((mycpv, _slot_separator, metadata["SLOT"])) - if 'repository' in metadata: - pkg = "".join((pkg, _repo_separator, metadata['repository'])) - cpv_slot_list = [pkg] + # At this point myrepo should be None, a valid name, or + # Package.UNKNOWN_REPO which we ignore. + if myrepo is not None and myrepo != Package.UNKNOWN_REPO: + pkg = "".join((pkg, _repo_separator, myrepo)) + cpv_slot_list = [pkg] + mycp=mysplit[0]+"/"+mysplit[1] # XXX- This is a temporary duplicate of code from the config constructor.