diff options
author | Marius Mauch <genone@gentoo.org> | 2006-10-26 16:18:00 +0000 |
---|---|---|
committer | Marius Mauch <genone@gentoo.org> | 2006-10-26 16:18:00 +0000 |
commit | 6f41323067c689a9c87516b298f0f9498d3e35ef (patch) | |
tree | 2cf3337d6fc1b24c4efbc40a1742b3df11bae11d | |
parent | c631bf42311f6b53e957234281755e9bb7500548 (diff) | |
download | portage-6f41323067c689a9c87516b298f0f9498d3e35ef.tar.gz portage-6f41323067c689a9c87516b298f0f9498d3e35ef.tar.bz2 portage-6f41323067c689a9c87516b298f0f9498d3e35ef.zip |
add function getlicensetexts() to extract license texts relevant to a given cpv (to be used by emerge masked by display)
svn path=/main/trunk/; revision=4826
-rw-r--r-- | pym/portage.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pym/portage.py b/pym/portage.py index c81e34479..2862db7cc 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3832,6 +3832,33 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): else: return mykey +def getlicensetexts(mycpv, settings=None, portdb=None, onlymasked=True): + if portdb is None: + portdb = globals()["portdb"] + if settings is None: + settings = config(clone=globals()["settings"]) + + license_data = portdb.aux_get(mycpv, ["LICENSE"])[0] + settings.setcpv(mycpv, mydb=portdb) + acceptable_licenses = settings.acceptable_licenses(mycpv) + + def str_matches(myatom): + return (not onlymasked) and (myatom in acceptable_licenses) + + license_list = dep_check(license_data, None, settings, + str_matches=str_matches)[1] + if onlymasked and "*" in acceptable_licenses: + license_list = [] + + rValue = {} + for lic in license_list: + # Account for overlays here? How? + licfilename = os.path.join(settings["PORTDIR"], "licenses", lic) + fd = open(licfilename, "r") + rValue[lic] = (licfilename, fd.read()) + fd.close() + return rValue + def getpmaskcomment(mycpv, settings=None, portdb=None): from portage_util import grablines if settings is None: |