Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] repoman: add a mini framework for checking eclasses, and fill it out
Date: Wed, 23 May 2012 21:24:05
Message-Id: 4FBD3FEB.9030401@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] repoman: add a mini framework for checking eclasses, and fill it out by Mike Frysinger
1 On 05/23/2012 12:21 PM, Mike Frysinger wrote:
2 > Rather than copying & pasting the same behavior for the different eclass
3 > checks, add a common class for them to extend. This makes adding more
4 > eclass checks trivial, and keeps down bitrot.
5 >
6 > This does abuse the checking interface slightly -- the eclass will change
7 > its category between unused and missing based on the checks.
8 >
9 > URL: https://bugs.gentoo.org/417159
10 > URL: https://bugs.gentoo.org/417231
11
12 It's fragile to keep all of these eclass interface definitions hardcoded
13 in python. For example, the _comprehensive checks are going to start
14 triggering repoman warnings every time that we add a new function to an
15 eclass. If we keep the eclass interface definitions in the tree with the
16 eclasses, then it will solve this problem, and it will also be possible
17 for overlays to fork eclasses and tweak interfaces.
18
19 > def new(self, pkg):
20 > - self._inherit_autotools = None
21 > - self._autotools_func_call = None
22 > - self._disabled = self._exempt_eclasses.intersection(pkg.inherited)
23 > + self.repoman_check_name = 'inherit.missing'
24 > + self._inherit_re = re.compile(r'^\s*inherit\s(.*\s)?%s(\s|$)' % self._eclass)
25 > + self._func_re = re.compile(r'\b(' + '|'.join(self._funcs) + r')\b')
26
27
28 The _inherit_re and _func_re regular expressions do not change from one
29 package to the next, so we can compile them inside the __init__
30 constructor instead, which is only called once in global scope.
31
32 > + # We can't use pkg.inherited because that tells us all the eclass that
33 > + # have been inherited and not just the ones we inherit directly.
34 > + self._inherit = False
35 > + self._func_call = False
36 > + if '_exempt_eclasses' in dir(self):
37 > + self._disabled = self._exempt_eclasses.intersection(pkg.inherited)
38 > + else:
39 > + self._disabled = False
40
41 It's more efficient to use hasattr(self, '_exempt_eclasses') than to use
42 '_exempt_eclasses' in dir(self).
43
44 --
45 Thanks,
46 Zac

Replies