1 |
commit: c5da59ba667ac384b8b9fec8dcf788f5a1fecc9d |
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: Sat Jan 30 20:25:23 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c5da59ba |
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 | 43 ++++++++++++++++++++++ |
20 |
pym/repoman/scanner.py | 21 +---------- |
21 |
7 files changed, 54 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 5420e51..be59b05 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..989d695 |
94 |
--- /dev/null |
95 |
+++ b/pym/repoman/modules/scan/ebuild/multicheck.py |
96 |
@@ -0,0 +1,43 @@ |
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 runInPkgs(self): |
135 |
+ return (False, []) |
136 |
+ |
137 |
+ @property |
138 |
+ def runInEbuilds(self): |
139 |
+ return (True, [self.check]) |
140 |
|
141 |
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py |
142 |
index 308b440..78ff053 100644 |
143 |
--- a/pym/repoman/scanner.py |
144 |
+++ b/pym/repoman/scanner.py |
145 |
@@ -3,7 +3,6 @@ |
146 |
from __future__ import print_function, unicode_literals |
147 |
|
148 |
import copy |
149 |
-import io |
150 |
import logging |
151 |
from itertools import chain |
152 |
from pprint import pformat |
153 |
@@ -13,11 +12,8 @@ from _emerge.Package import Package |
154 |
import portage |
155 |
from portage import normalize_path |
156 |
from portage import os |
157 |
-from portage import _encodings |
158 |
-from portage import _unicode_encode |
159 |
from portage.dep import Atom |
160 |
from portage.output import green |
161 |
-from repoman.checks.ebuilds.checks import run_checks |
162 |
from repoman.modules.commit import repochecks |
163 |
from repoman.profile import check_profiles, dev_profile_keywords, setup_profile |
164 |
from repoman.repos import repo_metadata |
165 |
@@ -294,7 +290,7 @@ class Scanner(object): |
166 |
('arches', 'ArchChecks'), ('depend', 'DependChecks'), |
167 |
('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'), |
168 |
('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'), |
169 |
- ('mtime', 'MtimeChecks'), |
170 |
+ ('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'), |
171 |
]: |
172 |
if mod[0]: |
173 |
mod_class = MODULE_CONTROLLER.get_class(mod[0]) |
174 |
@@ -323,21 +319,6 @@ class Scanner(object): |
175 |
continue |
176 |
|
177 |
# Syntax Checks |
178 |
- try: |
179 |
- # All ebuilds should have utf_8 encoding. |
180 |
- f = io.open( |
181 |
- _unicode_encode( |
182 |
- dynamic_data['ebuild'].full_path, encoding=_encodings['fs'], errors='strict'), |
183 |
- mode='r', encoding=_encodings['repo.content']) |
184 |
- try: |
185 |
- for check_name, e in run_checks(f, dynamic_data['pkg']): |
186 |
- self.qatracker.add_error( |
187 |
- check_name, dynamic_data['ebuild'].relative_path + ': %s' % e) |
188 |
- finally: |
189 |
- f.close() |
190 |
- except UnicodeDecodeError: |
191 |
- # A file.UTF8 failure will have already been recorded above. |
192 |
- pass |
193 |
|
194 |
if self.options.force: |
195 |
# The dep_check() calls are the most expensive QA test. If --force |