commit:     31fd105a9897fee5a77a893e23062c37195767e4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 17:36:26 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 22:59:33 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=31fd105a

repoman: Migrate DescriptionChecks to the plugin system

 pym/repoman/modules/scan/metadata/__init__.py        |  8 ++++++++
 .../scan/metadata}/description.py                    | 20 ++++++++++++++------
 pym/repoman/scanner.py                               |  5 +----
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/pym/repoman/modules/scan/metadata/__init__.py 
b/pym/repoman/modules/scan/metadata/__init__.py
index eba6565..2506521 100644
--- a/pym/repoman/modules/scan/metadata/__init__.py
+++ b/pym/repoman/modules/scan/metadata/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
                        'func_desc': {
                        },
                },
+               'description-metadata': {
+                       'name': "description",
+                       'class': "DescriptionChecks",
+                       'description': doc,
+                       'functions': ['check'],
+                       'func_desc': {
+                       },
+               },
        }
 }
 

diff --git a/pym/repoman/checks/ebuilds/variables/description.py 
b/pym/repoman/modules/scan/metadata/description.py
similarity index 66%
rename from pym/repoman/checks/ebuilds/variables/description.py
rename to pym/repoman/modules/scan/metadata/description.py
index a2b1057..3570607 100644
--- a/pym/repoman/checks/ebuilds/variables/description.py
+++ b/pym/repoman/modules/scan/metadata/description.py
@@ -9,20 +9,19 @@ from repoman.qa_data import max_desc_len
 class DescriptionChecks(object):
        '''Perform checks on the DESCRIPTION variable.'''
 
-       def __init__(self, qatracker):
+       def __init__(self, **kwargs):
                '''
                @param qatracker: QATracker instance
                '''
-               self.qatracker = qatracker
+               self.qatracker = kwargs.get('qatracker')
 
-       def check(self, pkg, ebuild):
+       def checkTooLong(self, **kwargs):
                '''
                @param pkg: Package in which we check (object).
                @param ebuild: Ebuild which we check (object).
                '''
-               self._checkTooLong(pkg, ebuild)
-
-       def _checkTooLong(self, pkg, ebuild):
+               ebuild = kwargs.get('ebuild')
+               pkg = kwargs.get('pkg')
                # 14 is the length of DESCRIPTION=""
                if len(pkg._metadata['DESCRIPTION']) > max_desc_len:
                        self.qatracker.add_error(
@@ -30,3 +29,12 @@ class DescriptionChecks(object):
                                "%s: DESCRIPTION is %d characters (max %d)" %
                                (ebuild.relative_path, len(
                                        pkg._metadata['DESCRIPTION']), 
max_desc_len))
+               return {'continue': False}
+
+       @property
+       def runInPkgs(self):
+               return (False, [])
+
+       @property
+       def runInEbuilds(self):
+               return (True, [self.checkTooLong])

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 955440e..bb856b8 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -21,7 +21,6 @@ from repoman.checks.ebuilds.checks import run_checks
 from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks
 from repoman.check_missingslot import check_missingslot
 from repoman.checks.ebuilds.use_flags import USEFlagChecks
-from repoman.checks.ebuilds.variables.description import DescriptionChecks
 from repoman.checks.ebuilds.variables.license import LicenseChecks
 from repoman.checks.ebuilds.variables.restrict import RestrictChecks
 from repoman.modules.commit import repochecks
@@ -216,7 +215,6 @@ class Scanner(object):
                # initialize our checks classes here before the big xpkg loop
                self.use_flag_checks = USEFlagChecks(self.qatracker, uselist)
                self.rubyeclasscheck = RubyEclassChecks(self.qatracker)
-               self.descriptioncheck = DescriptionChecks(self.qatracker)
                self.licensecheck = LicenseChecks(self.qatracker, liclist, 
liclist_deprecated)
                self.restrictcheck = RestrictChecks(self.qatracker)
 
@@ -301,6 +299,7 @@ class Scanner(object):
                        for mod in [('ebuild', 'Ebuild'), ('live', 
'LiveEclassChecks'),
                                ('eapi', 'EAPIChecks'), ('ebuild_metadata', 
'EbuildMetadata'),
                                ('thirdpartymirrors', 'ThirdPartyMirrors'),
+                               ('description', 'DescriptionChecks'),
                                ]:
                                if mod[0]:
                                        mod_class = 
MODULE_CONTROLLER.get_class(mod[0])
@@ -347,8 +346,6 @@ class Scanner(object):
                                                myqakey = var + ".virtual"
                                                
self.qatracker.add_error(myqakey, dynamic_data['ebuild'].relative_path)
 
-                       self.descriptioncheck.check(dynamic_data['pkg'], 
dynamic_data['ebuild'])
-
                        if dynamic_data['live_ebuild'] and 
self.repo_settings.repo_config.name == "gentoo":
                                self.liveeclasscheck.check(
                                        dynamic_data['pkg'], xpkg, 
dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, 
self.repo_metadata['pmaskdict'])

Reply via email to