From 6f41323067c689a9c87516b298f0f9498d3e35ef Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Thu, 26 Oct 2006 16:18:00 +0000 Subject: [PATCH] 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 --- pym/portage.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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: -- 2.26.2