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/modules/scan/metadata/, pym/repoman/, ...
Date: Mon, 25 Apr 2016 15:32:35
Message-Id: 1461598133.3dc78ff91eccd81c972ceadf59d059aabe9ccdbc.dolsen@gentoo
1 commit: 3dc78ff91eccd81c972ceadf59d059aabe9ccdbc
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Mar 15 18:40:06 2016 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Apr 25 15:28:53 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3dc78ff9
7
8 repoman: Create a new boolean Fuse type
9
10 Create a Fuse type which implememts a boolean as a one time fuse.
11 The Fuse is initialized True, then is pop()'d to become False.
12 Once the Fuse is blown, it can not be reset to True.
13 Convert the use of the dynamic_data variable 'allvalid' to a Fuse instance.
14
15 pym/repoman/fuse.py | 68 +++++++++++++++++++++++++++++
16 pym/repoman/modules/scan/ebuild/ebuild.py | 7 ++-
17 pym/repoman/modules/scan/ebuild/isebuild.py | 13 +++---
18 pym/repoman/modules/scan/metadata/unused.py | 2 +-
19 pym/repoman/scanner.py | 2 +
20 5 files changed, 83 insertions(+), 9 deletions(-)
21
22 diff --git a/pym/repoman/fuse.py b/pym/repoman/fuse.py
23 new file mode 100644
24 index 0000000..ac864fd
25 --- /dev/null
26 +++ b/pym/repoman/fuse.py
27 @@ -0,0 +1,68 @@
28 +
29 +'''
30 +fuse.py
31 +
32 +A tiny one-time-fuse class that uses a boolean to mimic the property of
33 +an electrical fuse. IT's good (True) until it is popped (bad, False).
34 +It is not resetable.
35 +'''
36 +
37 +
38 +class Fuse(object):
39 + '''A One time fuse style boolean instance'''
40 +
41 + __slots__ = ('_state')
42 +
43 + def __init__(self):
44 + self._state = True
45 +
46 + def pop(self):
47 + '''Blow's the fuse state (makes it False)'''
48 + self._state = False
49 +
50 + def __repr__(self):
51 + '''x.__repr__() <==> repr(x)'''
52 + return repr(self._state>0)
53 +
54 + def __str__(self):
55 + '''x.__str__() <==> str(x)'''
56 + return ['False', 'True'][self._state]
57 +
58 + def __bool__(self):
59 + '''self != 0'''
60 + return self._state != 0
61 +
62 + def __nonzero__(self):
63 + '''self != 0'''
64 + return self._state != 0
65 +
66 + def __abs__(self):
67 + '''x.__abs__() <==> abs(x)'''
68 + return [0, 1] [self._state]
69 +
70 + def __int__(self):
71 + '''int(self)'''
72 + return [0, 1][self._state]
73 +
74 + def __eq__(self, value):
75 + '''Return self==value.'''
76 + return self._state == value
77 +
78 + def __ne__(self, value):
79 + '''Return self!=value.'''
80 + return self._state != value
81 +
82 + def __ge__(self, value):
83 + '''Return self>=value.'''
84 + return self._state >= value
85 +
86 + def __gt__(self, value):
87 + return self._state > value
88 +
89 + def __le__(self, value):
90 + '''Return self<=value.'''
91 + return self._state <= value
92 +
93 + def __lt__(self, value):
94 + '''Return self<value.'''
95 + return self._state < value
96
97 diff --git a/pym/repoman/modules/scan/ebuild/ebuild.py b/pym/repoman/modules/scan/ebuild/ebuild.py
98 index e9a2cdd..540411f 100644
99 --- a/pym/repoman/modules/scan/ebuild/ebuild.py
100 +++ b/pym/repoman/modules/scan/ebuild/ebuild.py
101 @@ -127,13 +127,16 @@ class Ebuild(ScanBase):
102 def pkg_invalid(self, **kwargs):
103 '''Sets some pkg info and checks for invalid packages
104
105 - @returns: dictionary, including {pkg object, allvalid}
106 + @param validity_fuse: Fuse instance
107 + @returns: dictionary, including {pkg object}
108 '''
109 + fuse = kwargs.get('validity_fuse')
110 if self.pkg.invalid:
111 for k, msgs in self.pkg.invalid.items():
112 for msg in msgs:
113 self.qatracker.add_error(k, "%s: %s" % (self.relative_path, msg))
114 - return {'continue': True, 'allvalid': False, 'pkg': self.pkg}
115 + fuse.pop()
116 + return {'continue': True, 'pkg': self.pkg}
117 return {'continue': False, 'pkg': self.pkg}
118
119 @property
120
121 diff --git a/pym/repoman/modules/scan/ebuild/isebuild.py b/pym/repoman/modules/scan/ebuild/isebuild.py
122 index 1dffc6a..474a874 100644
123 --- a/pym/repoman/modules/scan/ebuild/isebuild.py
124 +++ b/pym/repoman/modules/scan/ebuild/isebuild.py
125 @@ -35,15 +35,16 @@ class IsEbuild(ScanBase):
126 @param checkdirlist: list of files in the current package directory
127 @param checkdir: current package directory path
128 @param xpkg: current package directory being checked
129 - @returns: dictionary, including {pkgs, allvalid, can_force}
130 + @param validity_fuse: Fuse instance
131 + @returns: dictionary, including {pkgs, can_force}
132 '''
133 checkdirlist = kwargs.get('checkdirlist')
134 checkdir = kwargs.get('checkdir')
135 xpkg = kwargs.get('xpkg')
136 + fuse = kwargs.get('validity_fuse')
137 self.continue_ = False
138 ebuildlist = []
139 pkgs = {}
140 - allvalid = True
141 for y in checkdirlist:
142 file_is_ebuild = y.endswith(".ebuild")
143 file_should_be_non_executable = y in no_exec or file_is_ebuild
144 @@ -62,15 +63,15 @@ class IsEbuild(ScanBase):
145 try:
146 myaux = dict(zip(allvars, self.portdb.aux_get(cpv, allvars)))
147 except KeyError:
148 - allvalid = False
149 + fuse.pop()
150 self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y))
151 continue
152 except IOError:
153 - allvalid = False
154 + fuse.pop()
155 self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y))
156 continue
157 if not portage.eapi_is_supported(myaux["EAPI"]):
158 - allvalid = False
159 + fuse.pop()
160 self.qatracker.add_error("EAPI.unsupported", os.path.join(xpkg, y))
161 continue
162 pkgs[pf] = Package(
163 @@ -85,7 +86,7 @@ class IsEbuild(ScanBase):
164 # positives confuse users.
165 self.continue_ = True
166
167 - return {'continue': self.continue_, 'pkgs': pkgs, 'allvalid': allvalid,
168 + return {'continue': self.continue_, 'pkgs': pkgs,
169 'can_force': not self.continue_}
170
171 @property
172
173 diff --git a/pym/repoman/modules/scan/metadata/unused.py b/pym/repoman/modules/scan/metadata/unused.py
174 index 2ca7466..9ff7e56 100644
175 --- a/pym/repoman/modules/scan/metadata/unused.py
176 +++ b/pym/repoman/modules/scan/metadata/unused.py
177 @@ -13,7 +13,7 @@ class UnusedCheck(ScanBase):
178 used_useflags = kwargs.get('used_useflags')
179 # check if there are unused local USE-descriptions in metadata.xml
180 # (unless there are any invalids, to avoid noise)
181 - if kwargs.get('allvalid'):
182 + if kwargs.get('validity_fuse'):
183 for myflag in muselist.difference(used_useflags):
184 self.qatracker.add_error(
185 "metadata.warning",
186
187 diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
188 index 86e389a..9c6f5ac 100644
189 --- a/pym/repoman/scanner.py
190 +++ b/pym/repoman/scanner.py
191 @@ -9,6 +9,7 @@ import portage
192 from portage import normalize_path
193 from portage import os
194 from portage.output import green
195 +from repoman.fuse import Fuse
196 from repoman.modules.commit import repochecks
197 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
198 from repoman.repos import repo_metadata
199 @@ -232,6 +233,7 @@ class Scanner(object):
200 'repolevel': self.repolevel,
201 'catdir': catdir,
202 'pkgdir': pkgdir,
203 + 'validity_fuse': Fuse()
204 }
205 # need to set it up for ==> self.modules or some other ordered list
206 for mod in ['Manifests', 'IsEbuild', 'KeywordChecks', 'FileChecks',