From 7301f68103e89ae015936a66aab1cba8d34fb829 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 21 Mar 2007 21:20:25 +0000 Subject: [PATCH] Merged from trunk 6257:6261 Catch a potential InvalidDependString exception. Add a docstring to config.getMissingLicenses(). Pass a list of USE flags into config.getMissingLicenses() so that the method can eventually be used for binary packages in addition to ebuilds. Fix a typo. svn path=/main/branches/prefix/; revision=6262 --- pym/emerge/__init__.py | 15 +++++++++++++-- pym/portage/__init__.py | 30 ++++++++++++++++++++++++------ pym/portage/dbapi/porttree.py | 7 ++++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index 1b4bfb9b9..f2b49f461 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -1694,9 +1694,20 @@ class depgraph: print comment oldcomment = comment licenses = portdb.aux_get(p, ["LICENSE"])[0] + uselist = [] + if "?" in licenses: + pkgsettings.setcpv(p, mydb=portdb) + uselist = pkgsettings.get("USE", "").split() missing_licenses = [] - for l in pkgsettings.getMissingLicenses( - licenses, p): + try: + missing_licenses = \ + pkgsettings.getMissingLicenses( + licenses, p, uselist) + except portage.exception.InvalidDependString: + # This will have already been reported + # above via mreasons. + pass + for l in missing_licenses: l_path = portdb.findLicensePath(l) if l in shown_licenses: continue diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 9feae3818..8b95b6854 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1536,7 +1536,7 @@ class config: noiselevel=-1) rValue.append("@"+group_name) if negate: - rvalue = ["-" + token for token in rValue] + rValue = ["-" + token for token in rValue] return rValue def validate(self): @@ -1758,7 +1758,22 @@ class config: if has_changed: self.reset(keeping_pkg=1,use_cache=use_cache) - def getMissingLicenses(self, licenses, cpv): + def getMissingLicenses(self, licenses, cpv, uselist): + """ + Take a LICENSE string and return a list any licenses that the user may + may need to accept for the given package. The returned list will not + contain any licenses that have already been accepted. This method + can throw an InvalidDependString exception. + + @param licenses: A raw LICENSE string as returned form dbapi.aux_get() + @type licenses: String + @param cpv: The package name (for package.license support) + @type cpv: String + @param uselist: A list of flags for evaluation of USE conditionals + @type uselist: List + @rtype: List + @return: A list of licenses that have not been accepted. + """ cpdict = self._plicensedict.get(dep_getkey(cpv), None) acceptable_licenses = self._accept_license.copy() if cpdict: @@ -1766,11 +1781,9 @@ class config: acceptable_licenses.update(cpdict[atom]) if "*" in acceptable_licenses: return [] - if "?" in licenses: - self.setcpv(cpv) license_struct = portage.dep.paren_reduce(licenses) license_struct = portage.dep.use_reduce( - license_struct, uselist=self["USE"].split()) + license_struct, uselist=uselist) license_struct = portage.dep.dep_opconvert(license_struct) return self._getMissingLicenses(license_struct, acceptable_licenses) @@ -4717,8 +4730,13 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if kmask: rValue.append(kmask+" keyword") + uselist = [] + if "?" in licenses: + settings.setcpv(mycpv, mydb=portdb) + uselist = settings.get("USE", "").split() try: - missing_licenses = settings.getMissingLicenses(licenses, mycpv) + missing_licenses = settings.getMissingLicenses( + licenses, mycpv, uselist) if missing_licenses: allowed_tokens = set(["||", "(", ")"]) allowed_tokens.update(missing_licenses) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 4118a4da4..af14499d6 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -685,8 +685,13 @@ class portdbapi(dbapi): hasstable = True if not match and ((hastesting and "~*" in pgroups) or (hasstable and "*" in pgroups) or "**" in pgroups): match=1 + uselist = [] + if "?" in licenses: + self.mysettings.setcpv(mycpv, mydb=self) + uselist = self.mysettings.get("USE", "").split() try: - if self.mysettings.getMissingLicenses(licenses, mycpv): + if self.mysettings.getMissingLicenses( + licenses, mycpv, uselist): match = 0 except InvalidDependString: match = 0 -- 2.26.2