Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/scan/ebuild/, pym/repoman/checks/ebuilds/
Date: Mon, 07 Mar 2016 21:53:30
Message-Id: 1457385662.248cad6988681b1d45aeb37a06a921df2406386b.dolsen@gentoo
1 commit: 248cad6988681b1d45aeb37a06a921df2406386b
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 4 04:44:05 2016 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Mar 7 21:21:02 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=248cad69
7
8 repoman: Create a new MultiCheck class plugin
9
10 Move ebuilds/ checks.py and errors.py to the scan/ebuild plugin.
11 Remove the checks_init from main(), initialize it in the MultiCheck
12 class where it is needed.
13
14 pym/repoman/checks/ebuilds/__init__.py | 0
15 pym/repoman/main.py | 2 --
16 pym/repoman/modules/scan/ebuild/__init__.py | 9 +++++
17 .../ebuilds => modules/scan/ebuild}/checks.py | 2 +-
18 .../ebuilds => modules/scan/ebuild}/errors.py | 0
19 pym/repoman/modules/scan/ebuild/multicheck.py | 39 ++++++++++++++++++++++
20 pym/repoman/scanner.py | 21 +-----------
21 7 files changed, 50 insertions(+), 23 deletions(-)
22
23 diff --git a/pym/repoman/checks/ebuilds/__init__.py b/pym/repoman/checks/ebuilds/__init__.py
24 deleted file mode 100644
25 index e69de29..0000000
26
27 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
28 index 8784685..890e034 100755
29 --- a/pym/repoman/main.py
30 +++ b/pym/repoman/main.py
31 @@ -26,7 +26,6 @@ from portage.util import formatter
32
33 from repoman.actions import Actions
34 from repoman.argparser import parse_args
35 -from repoman.checks.ebuilds.checks import checks_init
36 from repoman.qa_data import (
37 format_qa_output, format_qa_output_column, qahelp,
38 qawarnings, qacats)
39 @@ -65,7 +64,6 @@ def repoman_main(argv):
40 if options.experimental_inherit == 'y':
41 # This is experimental, so it's non-fatal.
42 qawarnings.add("inherit.missing")
43 - checks_init(experimental_inherit=True)
44
45 # Set this to False when an extraordinary issue (generally
46 # something other than a QA issue) makes it impossible to
47
48 diff --git a/pym/repoman/modules/scan/ebuild/__init__.py b/pym/repoman/modules/scan/ebuild/__init__.py
49 index a22e736..e712e4b 100644
50 --- a/pym/repoman/modules/scan/ebuild/__init__.py
51 +++ b/pym/repoman/modules/scan/ebuild/__init__.py
52 @@ -28,6 +28,15 @@ module_spec = {
53 'func_desc': {
54 },
55 },
56 + 'multicheck-module': {
57 + 'name': "multicheck",
58 + 'sourcefile': "multicheck",
59 + 'class': "MultiCheck",
60 + 'description': doc,
61 + 'functions': ['check'],
62 + 'func_kwargs': {
63 + },
64 + },
65 }
66 }
67
68
69 diff --git a/pym/repoman/checks/ebuilds/checks.py b/pym/repoman/modules/scan/ebuild/checks.py
70 similarity index 99%
71 rename from pym/repoman/checks/ebuilds/checks.py
72 rename to pym/repoman/modules/scan/ebuild/checks.py
73 index 7894e2b..8cdc230 100644
74 --- a/pym/repoman/checks/ebuilds/checks.py
75 +++ b/pym/repoman/modules/scan/ebuild/checks.py
76 @@ -21,7 +21,7 @@ from portage.eapi import (
77 eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard,
78 eapi_exports_AA, eapi_has_pkg_pretend)
79
80 -import repoman.checks.ebuilds.errors as errors
81 +from . import errors
82
83
84 class LineCheck(object):
85
86 diff --git a/pym/repoman/checks/ebuilds/errors.py b/pym/repoman/modules/scan/ebuild/errors.py
87 similarity index 100%
88 rename from pym/repoman/checks/ebuilds/errors.py
89 rename to pym/repoman/modules/scan/ebuild/errors.py
90
91 diff --git a/pym/repoman/modules/scan/ebuild/multicheck.py b/pym/repoman/modules/scan/ebuild/multicheck.py
92 new file mode 100644
93 index 0000000..8b85abf
94 --- /dev/null
95 +++ b/pym/repoman/modules/scan/ebuild/multicheck.py
96 @@ -0,0 +1,39 @@
97 +
98 +import io
99 +
100 +from portage import _encodings, _unicode_encode
101 +
102 +from .checks import run_checks, checks_init
103 +
104 +
105 +class MultiCheck(object):
106 + '''Class to run multiple different checks on an ebuild'''
107 +
108 + def __init__(self, **kwargs):
109 + self.qatracker = kwargs.get('qatracker')
110 + self.options = kwargs.get('options')
111 + checks_init(self.options.experimental_inherit == 'y')
112 +
113 + def check(self, **kwargs):
114 + ebuild = kwargs.get('ebuild')
115 + pkg = kwargs.get('pkg')
116 + try:
117 + # All ebuilds should have utf_8 encoding.
118 + f = io.open(
119 + _unicode_encode(ebuild.full_path, encoding=_encodings['fs'],
120 + errors='strict'),
121 + mode='r', encoding=_encodings['repo.content'])
122 + try:
123 + for check_name, e in run_checks(f, pkg):
124 + self.qatracker.add_error(
125 + check_name, ebuild.relative_path + ': %s' % e)
126 + finally:
127 + f.close()
128 + except UnicodeDecodeError:
129 + # A file.UTF8 failure will have already been recorded.
130 + pass
131 + return {'continue': False}
132 +
133 + @property
134 + def runInEbuilds(self):
135 + return (True, [self.check])
136
137 diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
138 index 308b440..78ff053 100644
139 --- a/pym/repoman/scanner.py
140 +++ b/pym/repoman/scanner.py
141 @@ -3,7 +3,6 @@
142 from __future__ import print_function, unicode_literals
143
144 import copy
145 -import io
146 import logging
147 from itertools import chain
148 from pprint import pformat
149 @@ -13,11 +12,8 @@ from _emerge.Package import Package
150 import portage
151 from portage import normalize_path
152 from portage import os
153 -from portage import _encodings
154 -from portage import _unicode_encode
155 from portage.dep import Atom
156 from portage.output import green
157 -from repoman.checks.ebuilds.checks import run_checks
158 from repoman.modules.commit import repochecks
159 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
160 from repoman.repos import repo_metadata
161 @@ -294,7 +290,7 @@ class Scanner(object):
162 ('arches', 'ArchChecks'), ('depend', 'DependChecks'),
163 ('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'),
164 ('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
165 - ('mtime', 'MtimeChecks'),
166 + ('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
167 ]:
168 if mod[0]:
169 mod_class = MODULE_CONTROLLER.get_class(mod[0])
170 @@ -323,21 +319,6 @@ class Scanner(object):
171 continue
172
173 # Syntax Checks
174 - try:
175 - # All ebuilds should have utf_8 encoding.
176 - f = io.open(
177 - _unicode_encode(
178 - dynamic_data['ebuild'].full_path, encoding=_encodings['fs'], errors='strict'),
179 - mode='r', encoding=_encodings['repo.content'])
180 - try:
181 - for check_name, e in run_checks(f, dynamic_data['pkg']):
182 - self.qatracker.add_error(
183 - check_name, dynamic_data['ebuild'].relative_path + ': %s' % e)
184 - finally:
185 - f.close()
186 - except UnicodeDecodeError:
187 - # A file.UTF8 failure will have already been recorded above.
188 - pass
189
190 if self.options.force:
191 # The dep_check() calls are the most expensive QA test. If --force