commit:     60fbda473665c8b4d5adf00323923538adc6357e
Author:     Tom Wijsman <tomwij <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  6 15:09:43 2014 +0000
Commit:     Tom Wijsman <tomwij <AT> gentoo <DOT> org>
CommitDate: Fri Jun  6 15:09:43 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=60fbda47

repoman/main.py: Split LICENSE checks to checks/ebuild/variables/

---
 pym/repoman/checks/ebuilds/variables/license.py | 47 +++++++++++++++++++++++++
 pym/repoman/main.py                             | 21 +++--------
 2 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/pym/repoman/checks/ebuilds/variables/license.py 
b/pym/repoman/checks/ebuilds/variables/license.py
new file mode 100644
index 0000000..bdc859c
--- /dev/null
+++ b/pym/repoman/checks/ebuilds/variables/license.py
@@ -0,0 +1,47 @@
+
+'''description.py
+Perform checks on the LICENSE variable.
+'''
+
+# import our initialized portage instance
+from repoman._portage import portage
+
+
+class LicenseChecks(object):
+       '''Perform checks on the LICENSE variable.'''
+
+       def __init__(self, qatracker, liclist, liclist_deprecated):
+               '''
+               @param qatracker: QATracker instance
+               @param liclist: List of licenses.
+               @param liclist: List of deprecated licenses.
+               '''
+               self.qatracker = qatracker
+               self.liclist = liclist
+               self.liclist_deprecated = liclist_deprecated
+
+       def check(
+               self, pkg, package, ebuild, y_ebuild):
+               '''
+               @param pkg: Package in which we check (object).
+               @param package: Package in which we check (string).
+               @param ebuild: Ebuild which we check (object).
+               @param y_ebuild: Ebuild which we check (string).
+               '''
+
+               # Parse the LICENSE variable, remove USE conditions and flatten 
it.
+               licenses = portage.dep.use_reduce(
+                       pkg._metadata["LICENSE"], matchall=1, flat=True)
+
+               # Check each entry to ensure that it exists in 
${PORTDIR}/licenses/.
+               for lic in licenses:
+                       # Need to check for "||" manually as no portage
+                       # function will remove it without removing values.
+                       if lic not in self.liclist and lic != "||":
+                               self.qatracker.add_error(
+                                       "LICENSE.invalid",
+                                       package + "/" + y_ebuild + ".ebuild: 
%s" % lic)
+                       elif lic in self.liclist_deprecated:
+                               self.qatracker.add_error(
+                                       "LICENSE.deprecated",
+                                       "%s: %s" % (ebuild.relative_path, lic))

diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 83dfd07..6667d6b 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -53,6 +53,7 @@ from repoman.checks.ebuilds.pkgmetadata import PkgMetadata
 from repoman.checks.ebuilds.use_flags import USEFlagChecks
 from repoman.checks.ebuilds.variables.description import DescriptionChecks
 from repoman.checks.ebuilds.variables.eapi import EAPIChecks
+from repoman.checks.ebuilds.variables.license import LicenseChecks
 from repoman.ebuild import Ebuild
 from repoman.errors import err
 from repoman.modules.commit import repochecks
@@ -289,6 +290,7 @@ liveeclasscheck = LiveEclassChecks(qatracker)
 rubyeclasscheck = RubyEclassChecks(qatracker)
 eapicheck = EAPIChecks(qatracker, repo_settings)
 descriptioncheck = DescriptionChecks(qatracker)
+licensecheck = LicenseChecks(qatracker, liclist, liclist_deprecated)
 ######################
 
 for xpkg in effective_scanlist:
@@ -597,22 +599,9 @@ for xpkg in effective_scanlist:
 
                # license checks
                if not badlicsyntax:
-                       # Parse the LICENSE variable, remove USE conditions and
-                       # flatten it.
-                       licenses = portage.dep.use_reduce(myaux["LICENSE"], 
matchall=1, flat=True)
-                       # Check each entry to ensure that it exists in PORTDIR's
-                       # license directory.
-                       for lic in licenses:
-                               # Need to check for "||" manually as no portage
-                               # function will remove it without removing 
values.
-                               if lic not in liclist and lic != "||":
-                                       qatracker.add_error(
-                                               "LICENSE.invalid",
-                                               xpkg + "/" + y_ebuild + 
".ebuild: %s" % lic)
-                               elif lic in liclist_deprecated:
-                                       qatracker.add_error(
-                                               "LICENSE.deprecated",
-                                               "%s: %s" % 
(ebuild.relative_path, lic))
+                       #################
+                       licensecheck.check(pkg, xpkg, ebuild, y_ebuild)
+                       #################
 
                # restrict checks
                myrestrict = None

Reply via email to