From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 985D358973 for ; Sat, 30 Jan 2016 06:59:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 46F5421C002; Sat, 30 Jan 2016 06:59:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1D60C21C046 for ; Sat, 30 Jan 2016 06:59:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 36B05340CCD for ; Sat, 30 Jan 2016 06:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B3FAAD25 for ; Sat, 30 Jan 2016 06:58:54 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1454136717.6a054584e7514cba37b37aa45c961f3427e3c7bc.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/ebuilds/, pym/repoman/modules/scan/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/__init__.py pym/repoman/checks/ebuilds/checks.py pym/repoman/checks/ebuilds/errors.py pym/repoman/main.py pym/repoman/modules/scan/ebuild/__init__.py pym/repoman/modules/scan/ebuild/checks.py pym/repoman/modules/scan/ebuild/errors.py pym/repoman/modules/scan/ebuild/multicheck.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/checks/ebuilds/ pym/repoman/ pym/repoman/modules/scan/ebuild/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 6a054584e7514cba37b37aa45c961f3427e3c7bc X-VCS-Branch: repoman Date: Sat, 30 Jan 2016 06:58:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a4e2841a-5c98-4b4f-8b42-3acc7074146e X-Archives-Hash: 43541590761d219a2e70d3e36923c179 commit: 6a054584e7514cba37b37aa45c961f3427e3c7bc Author: Brian Dolbec gentoo org> AuthorDate: Mon Jan 4 04:44:05 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 30 06:51:57 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a054584 repoman: Create a new MultiCheck class plugin Move ebuilds/ checks.py and errors.py to the scan/ebuild plugin. Remove the checks_init from main(), initialize it in the MultiCheck class where it is needed. pym/repoman/checks/ebuilds/__init__.py | 0 pym/repoman/main.py | 2 - pym/repoman/modules/scan/ebuild/__init__.py | 9 +++++ .../ebuilds => modules/scan/ebuild}/checks.py | 2 +- .../ebuilds => modules/scan/ebuild}/errors.py | 0 pym/repoman/modules/scan/ebuild/multicheck.py | 43 ++++++++++++++++++++++ pym/repoman/scanner.py | 21 +---------- 7 files changed, 54 insertions(+), 23 deletions(-) diff --git a/pym/repoman/checks/ebuilds/__init__.py b/pym/repoman/checks/ebuilds/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 8784685..890e034 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -26,7 +26,6 @@ from portage.util import formatter from repoman.actions import Actions from repoman.argparser import parse_args -from repoman.checks.ebuilds.checks import checks_init from repoman.qa_data import ( format_qa_output, format_qa_output_column, qahelp, qawarnings, qacats) @@ -65,7 +64,6 @@ def repoman_main(argv): if options.experimental_inherit == 'y': # This is experimental, so it's non-fatal. qawarnings.add("inherit.missing") - checks_init(experimental_inherit=True) # Set this to False when an extraordinary issue (generally # something other than a QA issue) makes it impossible to diff --git a/pym/repoman/modules/scan/ebuild/__init__.py b/pym/repoman/modules/scan/ebuild/__init__.py index a22e736..e712e4b 100644 --- a/pym/repoman/modules/scan/ebuild/__init__.py +++ b/pym/repoman/modules/scan/ebuild/__init__.py @@ -28,6 +28,15 @@ module_spec = { 'func_desc': { }, }, + 'multicheck-module': { + 'name': "multicheck", + 'sourcefile': "multicheck", + 'class': "MultiCheck", + 'description': doc, + 'functions': ['check'], + 'func_kwargs': { + }, + }, } } diff --git a/pym/repoman/checks/ebuilds/checks.py b/pym/repoman/modules/scan/ebuild/checks.py similarity index 99% rename from pym/repoman/checks/ebuilds/checks.py rename to pym/repoman/modules/scan/ebuild/checks.py index 5420e51..be59b05 100644 --- a/pym/repoman/checks/ebuilds/checks.py +++ b/pym/repoman/modules/scan/ebuild/checks.py @@ -21,7 +21,7 @@ from portage.eapi import ( eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, eapi_exports_AA, eapi_has_pkg_pretend) -import repoman.checks.ebuilds.errors as errors +from . import errors class LineCheck(object): diff --git a/pym/repoman/checks/ebuilds/errors.py b/pym/repoman/modules/scan/ebuild/errors.py similarity index 100% rename from pym/repoman/checks/ebuilds/errors.py rename to pym/repoman/modules/scan/ebuild/errors.py diff --git a/pym/repoman/modules/scan/ebuild/multicheck.py b/pym/repoman/modules/scan/ebuild/multicheck.py new file mode 100644 index 0000000..989d695 --- /dev/null +++ b/pym/repoman/modules/scan/ebuild/multicheck.py @@ -0,0 +1,43 @@ + +import io + +from portage import _encodings, _unicode_encode + +from .checks import run_checks, checks_init + + +class MultiCheck(object): + '''Class to run multiple different checks on an ebuild''' + + def __init__(self, **kwargs): + self.qatracker = kwargs.get('qatracker') + self.options = kwargs.get('options') + checks_init(self.options.experimental_inherit == 'y') + + def check(self, **kwargs): + ebuild = kwargs.get('ebuild') + pkg = kwargs.get('pkg') + try: + # All ebuilds should have utf_8 encoding. + f = io.open( + _unicode_encode(ebuild.full_path, encoding=_encodings['fs'], + errors='strict'), + mode='r', encoding=_encodings['repo.content']) + try: + for check_name, e in run_checks(f, pkg): + self.qatracker.add_error( + check_name, ebuild.relative_path + ': %s' % e) + finally: + f.close() + except UnicodeDecodeError: + # A file.UTF8 failure will have already been recorded. + pass + return {'continue': False} + + @property + def runInPkgs(self): + return (False, []) + + @property + def runInEbuilds(self): + return (True, [self.check]) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index dbbbb15..9fe5f26 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -3,7 +3,6 @@ from __future__ import print_function, unicode_literals import copy -import io import logging from itertools import chain from pprint import pformat @@ -13,11 +12,8 @@ from _emerge.Package import Package import portage from portage import normalize_path from portage import os -from portage import _encodings -from portage import _unicode_encode from portage.dep import Atom from portage.output import green -from repoman.checks.ebuilds.checks import run_checks from repoman.modules.commit import repochecks from repoman.profile import check_profiles, dev_profile_keywords, setup_profile from repoman.repos import repo_metadata @@ -294,7 +290,7 @@ class Scanner(object): ('arches', 'ArchChecks'), ('depend', 'DependChecks'), ('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'), ('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'), - ('mtime', 'MtimeChecks'), + ('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'), ]: if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) @@ -323,21 +319,6 @@ class Scanner(object): continue # Syntax Checks - try: - # All ebuilds should have utf_8 encoding. - f = io.open( - _unicode_encode( - dynamic_data['ebuild'].full_path, encoding=_encodings['fs'], errors='strict'), - mode='r', encoding=_encodings['repo.content']) - try: - for check_name, e in run_checks(f, dynamic_data['pkg']): - self.qatracker.add_error( - check_name, dynamic_data['ebuild'].relative_path + ': %s' % e) - finally: - f.close() - except UnicodeDecodeError: - # A file.UTF8 failure will have already been recorded above. - pass if self.options.force: # The dep_check() calls are the most expensive QA test. If --force