Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/
Date: Wed, 30 May 2012 23:20:56
Message-Id: 1338420027.597826a1cabf654f9b3fff88425d04303e921577.zmedico@gentoo
1 commit: 597826a1cabf654f9b3fff88425d04303e921577
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 30 23:20:27 2012 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed May 30 23:20:27 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=597826a1
7
8 InheritEclass: move eclass info to a dict
9
10 This handles the info more like it will be handled when we parse it
11 directly from eclasses.
12
13 ---
14 pym/repoman/checks.py | 175 +++++++++++++++++++++++++-----------------------
15 1 files changed, 91 insertions(+), 84 deletions(-)
16
17 diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
18 index 94dcfbe..5d56888 100644
19 --- a/pym/repoman/checks.py
20 +++ b/pym/repoman/checks.py
21 @@ -6,13 +6,14 @@
22 and correctness of an ebuild."""
23
24 import codecs
25 +from itertools import chain
26 import re
27 import time
28 import repoman.errors as errors
29 import portage
30 from portage.eapi import eapi_supports_prefix, eapi_has_implicit_rdepend, \
31 eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, \
32 - eapi_exports_AA, eapi_exports_KV
33 + eapi_exports_AA
34
35 class LineCheck(object):
36 """Run a check on a line of an ebuild."""
37 @@ -452,14 +453,19 @@ class InheritEclass(LineCheck):
38 Base class for checking for missing inherits, as well as excess inherits.
39
40 Args:
41 - _eclass: Set to the name of your eclass.
42 - _funcs: A tuple of functions that this eclass provides.
43 - _comprehensive: Is the list of functions complete?
44 - _exempt_eclasses: If these eclasses are inherited, disable the missing
45 + eclass: Set to the name of your eclass.
46 + funcs: A tuple of functions that this eclass provides.
47 + comprehensive: Is the list of functions complete?
48 + exempt_eclasses: If these eclasses are inherited, disable the missing
49 inherit check.
50 """
51
52 - def __init__(self):
53 + def __init__(self, eclass, funcs=None, comprehensive=False,
54 + exempt_eclasses=None):
55 + self._eclass = eclass
56 + self._funcs = funcs
57 + self._comprehensive = comprehensive
58 + self._exempt_eclasses = exempt_eclasses
59 self._inherit_re = re.compile(r'^\s*inherit\s(.*\s)?%s(\s|$)' % self._eclass)
60 self._func_re = re.compile(r'\b(' + '|'.join(self._funcs) + r')\b')
61
62 @@ -469,7 +475,7 @@ class InheritEclass(LineCheck):
63 # have been inherited and not just the ones we inherit directly.
64 self._inherit = False
65 self._func_call = False
66 - if hasattr(self, '_exempt_eclasses'):
67 + if self._exempt_eclasses is not None:
68 self._disabled = any(x in pkg.inherited for x in self._exempt_eclasses)
69 else:
70 self._disabled = False
71 @@ -493,78 +499,80 @@ class InheritEclass(LineCheck):
72 self.repoman_check_name = 'inherit.unused'
73 yield 'no function called from %s.eclass; please drop' % self._eclass
74
75 -class InheritAutotools(InheritEclass):
76 - _eclass = 'autotools'
77 - _funcs = (
78 - 'eaclocal', 'eautoconf', 'eautoheader',
79 - 'eautomake', 'eautoreconf', '_elibtoolize',
80 - 'eautopoint'
81 - )
82 - _comprehensive = True
83 -
84 - # Exempt eclasses:
85 - # git - An EGIT_BOOTSTRAP variable may be used to call one of
86 - # the autotools functions.
87 - # subversion - An ESVN_BOOTSTRAP variable may be used to call one of
88 - # the autotools functions.
89 - _exempt_eclasses = frozenset(['git', 'subversion', 'autotools-utils'])
90 -
91 -class InheritEutils(InheritEclass):
92 - _eclass = 'eutils'
93 - _funcs = (
94 - 'estack_push', 'estack_pop', 'eshopts_push', 'eshopts_pop',
95 - 'eumask_push', 'eumask_pop', 'epatch', 'epatch_user',
96 - 'emktemp', 'edos2unix', 'in_iuse', 'use_if_iuse', 'usex',
97 - 'makeopts_jobs'
98 - )
99 - _comprehensive = False
100 -
101 - # These are "eclasses are the whole ebuild" type thing.
102 - _exempt_eclasses = frozenset(['toolchain', 'toolchain-binutils'])
103 -
104 -class InheritFlagOMatic(InheritEclass):
105 - _eclass = 'flag-o-matic'
106 - _funcs = (
107 - 'filter-(ld)?flags', 'strip-flags', 'strip-unsupported-flags',
108 - 'append-((ld|c(pp|xx)?))?flags', 'append-libs',
109 - )
110 - _comprehensive = False
111 -
112 -class InheritLibtool(InheritEclass):
113 - _eclass = 'libtool'
114 - _funcs = (
115 - 'elibtoolize',
116 - )
117 - _comprehensive = True
118 -
119 -class InheritMultilib(InheritEclass):
120 - _eclass = 'multilib'
121 - _funcs = (
122 - 'get_libdir',
123 - )
124 - _comprehensive = False
125 -
126 -class InheritPrefix(InheritEclass):
127 - _eclass = 'prefix'
128 - _funcs = (
129 - 'eprefixify',
130 - )
131 - _comprehensive = True
132 -
133 -class InheritToolchainFuncs(InheritEclass):
134 - _eclass = 'toolchain-funcs'
135 - _funcs = (
136 - 'gen_usr_ldscript',
137 - )
138 - _comprehensive = False
139 -
140 -class InheritUser(InheritEclass):
141 - _eclass = 'user'
142 - _funcs = (
143 - 'enewuser', 'enewgroup',
144 - 'egetent', 'egethome', 'egetshell'
145 - )
146 - _comprehensive = True
147 +_eclass_info = {
148 + 'autotools': {
149 + 'funcs': (
150 + 'eaclocal', 'eautoconf', 'eautoheader',
151 + 'eautomake', 'eautoreconf', '_elibtoolize',
152 + 'eautopoint'
153 + ),
154 + 'comprehensive': True,
155 +
156 + # Exempt eclasses:
157 + # git - An EGIT_BOOTSTRAP variable may be used to call one of
158 + # the autotools functions.
159 + # subversion - An ESVN_BOOTSTRAP variable may be used to call one of
160 + # the autotools functions.
161 + 'exempt_eclasses': ('git', 'subversion', 'autotools-utils')
162 + },
163 +
164 + 'eutils': {
165 + 'funcs': (
166 + 'estack_push', 'estack_pop', 'eshopts_push', 'eshopts_pop',
167 + 'eumask_push', 'eumask_pop', 'epatch', 'epatch_user',
168 + 'emktemp', 'edos2unix', 'in_iuse', 'use_if_iuse', 'usex',
169 + 'makeopts_jobs'
170 + ),
171 + 'comprehensive': False,
172 +
173 + # These are "eclasses are the whole ebuild" type thing.
174 + 'exempt_eclasses': frozenset(['toolchain', 'toolchain-binutils'])
175 + },
176 +
177 + 'flag-o-matic': {
178 + 'funcs': (
179 + 'filter-(ld)?flags', 'strip-flags', 'strip-unsupported-flags',
180 + 'append-((ld|c(pp|xx)?))?flags', 'append-libs',
181 + ),
182 + 'comprehensive': False
183 + },
184 +
185 + 'libtool': {
186 + 'funcs': (
187 + 'elibtoolize',
188 + ),
189 + 'comprehensive': True
190 + },
191 +
192 + 'multilib': {
193 + 'funcs': (
194 + 'get_libdir',
195 + ),
196 + 'comprehensive': False
197 + },
198 +
199 + 'prefix': {
200 + 'funcs': (
201 + 'eprefixify',
202 + ),
203 + 'comprehensive': True
204 + },
205 +
206 + 'toolchain-funcs': {
207 + 'funcs': (
208 + 'gen_usr_ldscript',
209 + ),
210 + 'comprehensive': False
211 + },
212 +
213 + 'user': {
214 + 'funcs': (
215 + 'enewuser', 'enewgroup',
216 + 'egetent', 'egethome', 'egetshell'
217 + ),
218 + 'comprehensive': True
219 + }
220 +}
221
222 class IUseUndefined(LineCheck):
223 """
224 @@ -739,20 +747,19 @@ class PortageInternal(LineCheck):
225 if m is not None:
226 return ("'%s'" % m.group(2)) + " called on line: %d"
227
228 -_constant_checks = tuple((c() for c in (
229 +_constant_checks = tuple(chain((c() for c in (
230 EbuildHeader, EbuildWhitespace, EbuildBlankLine, EbuildQuote,
231 EbuildAssignment, Eapi3EbuildAssignment, EbuildUselessDodoc,
232 EbuildUselessCdS, EbuildNestedDie,
233 EbuildPatches, EbuildQuotedA, EapiDefinition,
234 - ImplicitRuntimeDeps, InheritAutotools, InheritDeprecated, InheritEutils,
235 - InheritFlagOMatic, InheritMultilib, InheritLibtool, InheritPrefix,
236 - InheritToolchainFuncs, InheritUser, IUseUndefined,
237 + ImplicitRuntimeDeps, IUseUndefined,
238 EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS, NoAsNeeded,
239 DeprecatedBindnowFlags, SrcUnpackPatches, WantAutoDefaultValue,
240 SrcCompileEconf, Eapi3DeprecatedFuncs, NoOffsetWithHelpers,
241 Eapi4IncompatibleFuncs, Eapi4GoneVars, BuiltWithUse,
242 PreserveOldLib, SandboxAddpredict, PortageInternal,
243 - DeprecatedUseq, DeprecatedHasq)))
244 + DeprecatedUseq, DeprecatedHasq)),
245 + (InheritEclass(k, **kwargs) for k, kwargs in _eclass_info.items())))
246
247 _here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
248 _ignore_comment_re = re.compile(r'^\s*#')