Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
Date: Tue, 17 Jul 2018 13:17:34
Message-Id: 1531833265.97de79100b7e0b85c93c6d8b48eb3fbae4a7b516.grknight@gentoo
1 commit: 97de79100b7e0b85c93c6d8b48eb3fbae4a7b516
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 17 13:14:25 2018 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 17 13:14:25 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=97de7910
7
8 mask_check.py: Have print statements work in Python 3
9
10 Fixes alerts from cron
11
12 package.mask/mask_check.py | 90 +++++++++++++++++++++++-----------------------
13 1 file changed, 45 insertions(+), 45 deletions(-)
14
15 diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
16 index 92af0c6..77b493a 100755
17 --- a/package.mask/mask_check.py
18 +++ b/package.mask/mask_check.py
19 @@ -1,5 +1,5 @@
20 #!/usr/bin/env python
21 -# Copyright 1999-2011 Gentoo Foundation
22 +# Copyright 1999-2018 Gentoo Foundation
23 # Distributed under the terms of the GNU General Public License v2
24
25 # python mask_check.py $(find /usr/portage/profiles -type f -name '*.mask' -not -regex '.*/prefix/.*')
26 @@ -40,9 +40,9 @@ def pkgcmp_atom(pkgdir, pkg):
27
28 revre = re.compile( ("^" + re.escape(ppkg) + "(-r\d+)?.ebuild$") )
29
30 -# print "DBG: checking for %s" % pkg
31 -# print "DBG: Got %i ebuilds:" % len(ebuilds)
32 -# print ebuilds
33 +# print("DBG: checking for %s" % pkg)
34 +# print("DBG: Got %i ebuilds:" % len(ebuilds))
35 +# print(ebuilds)
36
37 for ebuild in ebuilds:
38 # workaround? for - prefix
39 @@ -52,24 +52,24 @@ def pkgcmp_atom(pkgdir, pkg):
40 if pkg.startswith( ("=", "~") ):
41 if pkg.startswith("~"):
42 if revre.match(ebuild):
43 -# print "DBG: revmatch '%s' '%s'" % (pkg, ebuild)
44 +# print("DBG: revmatch '%s' '%s'" % (pkg, ebuild))
45 return 1
46 else:
47 -# print "DBG: revmatch continue"
48 +# print("DBG: revmatch continue")
49 continue
50 if pkg.endswith("*"):
51 if ebuild.startswith(ppkg):
52 -# print "DBG: startswith '%s' '%s'" % (pkg, ebuild)
53 +# print("DBG: startswith '%s' '%s'" % (pkg, ebuild))
54 return 1
55 else:
56 -# print "DBG: startswith continue"
57 +# print("DBG: startswith continue")
58 continue
59 else:
60 if ebuild == (ppkg + ".ebuild"):
61 -# print "DBG: '%s' == '%s'" % (ppkg, ppkg)
62 +# print("DBG: '%s' == '%s'" % (ppkg, ppkg))
63 return 1
64 else:
65 -# print "DBG: == continue"
66 +# print("DBG: == continue")
67 continue
68
69 if pkg.startswith( (">=", ">", "<=", "<") ):
70 @@ -86,38 +86,38 @@ def pkgcmp_atom(pkgdir, pkg):
71 if ourpkg[2] != "r0":
72 ourpkgv = ourpkgv + "-" + ourpkg[2]
73
74 -# print "MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv))
75 +# print("MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv)))
76
77 if pkg.startswith(">="):
78 if vercmp(mypkgv, ourpkgv) <= 0:
79 -# print "HIT: '%s' >= '%s'" % (ourpkg, mypkg)
80 +# print("HIT: '%s' >= '%s'" % (ourpkg, mypkg))
81 return 1
82 else:
83 -# print ">= continue"
84 +# print(">= continue")
85 continue
86 if pkg.startswith(">") and not pkg.startswith(">="):
87 if vercmp(mypkgv, ourpkgv) < 0:
88 -# print "HIT: '%s' > '%s'" % (ourpkg, mypkg)
89 +# print("HIT: '%s' > '%s'" % (ourpkg, mypkg))
90 return 1
91 else:
92 -# print "> continue"
93 +# print("> continue")
94 continue
95 if pkg.startswith("<="):
96 if vercmp(mypkgv, ourpkgv) >= 0:
97 -# print "HIT: '%s' <= '%s'" % (ourpkg, mypkg)
98 +# print("HIT: '%s' <= '%s'" % (ourpkg, mypkg))
99 return 1
100 else:
101 -# print "<= continue"
102 +# print("<= continue"
103 continue
104 if pkg.startswith("<") and not pkg.startswith("<="):
105 if vercmp(mypkgv, ourpkgv) > 0:
106 -# print "HIT: '%s' < '%s'" % (ourpkg, mypkg)
107 +# print("HIT: '%s' < '%s'" % (ourpkg, mypkg))
108 return 1
109 else:
110 -# print "< continue"
111 +# print("< continue")
112 continue
113
114 -# print "Nothing found... '%s' is invalid" % pkg
115 +# print("Nothing found... '%s' is invalid" % pkg)
116 return 0
117
118 def check_locuse(portdir, pkg, invalid):
119 @@ -196,26 +196,26 @@ def check_use(portdir, line):
120 else:
121 _flag = "%s_%s" % (basename(usedesc_f).replace(".desc", ""), _flag)
122 globuse.append(_flag)
123 -# print "GLOB: ", _flag
124 +# print("GLOB: ", _flag)
125
126 usedesc_fd.close()
127
128 -# print globuse
129 +# print(globuse)
130 # exit(1)
131
132 for flag in useflags:
133 if not flag in globuse:
134 # nothing found
135 invalid.append(flag)
136 -# print "Add useflag %s" %flag
137 +# print("Add useflag %s" %flag)
138
139 # check metadata.xml
140 if invalid:
141 invalid = check_locuse(portdir, pkg, invalid)
142
143
144 -# print portdir, pkg, useflags
145 -# print globuse
146 +# print(portdir, pkg, useflags)
147 +# print(globuse)
148
149 if invalid:
150 return (pkg, invalid)
151 @@ -224,24 +224,24 @@ def check_use(portdir, line):
152
153 # <cat>/<pkg> <use> ...
154 def check_pkg(portdir, line):
155 -# print "PKGM1:", line
156 +# print("PKGM1:", line)
157 pkgm = line.split(" ")[0]
158 -# print "PKGM2:", pkgm
159 -# print "DBG:", line.split(" ")
160 +# print("PKGM2:", pkgm)
161 +# print("DBG:", line.split(" "))
162
163 if pkgm.startswith("-"):
164 pkgm = pkgm[1:]
165
166 if pkgm.startswith(OPERATORS):
167 pkg = []
168 -# print "DBG1: %s" % pkgm
169 +# print("DBG1: %s" % pkgm)
170 plain_pkg = strip_atoms(pkgm)
171 -# print "DBG2: %s" % plain_pkg
172 +# print("DBG2: %s" % plain_pkg)
173
174 pkg = pkgsplit(plain_pkg)
175 if not pkg:
176 - print >> stderr, "Error encountered during pkgsplit(), please contact idl0r@g.o including the whole output!"
177 - print >> stderr, "1: %s; 2: %s" % (pkgm, plain_pkg)
178 + print("Error encountered during pkgsplit(), please contact idl0r@g.o including the whole output!", file=stderr)
179 + print("1: %s; 2: %s" % (pkgm, plain_pkg), file=stderr)
180 return 0
181
182 plain_pkg = strip_atoms(pkg[0])
183 @@ -305,33 +305,33 @@ def obsolete_pmask(portdir = None, package_mask=None):
184
185 # don't check useflags with check_pkg
186 if line.find("/") != -1 and not check_pkg(portdir, line):
187 -# print "Add whole entry: '%s'" % line
188 +# print("Add whole entry: '%s'" % line)
189 invalid_entries.append(line)
190 else:
191 invalid_use = check_use(portdir, line)
192 if invalid_use:
193 -# print "Add useflags: '%s %s'" % (invalid_use[0], invalid_use[1])
194 +# print("Add useflags: '%s %s'" % (invalid_use[0], invalid_use[1]))
195 invalid_entries.append(invalid_use)
196
197 pmask.close()
198
199 if invalid_entries:
200 - print "Found %i invalid/obsolete entries in %s:" % (len(invalid_entries), package_mask)
201 + print("Found %i invalid/obsolete entries in %s:" % (len(invalid_entries), package_mask))
202 for invalid in invalid_entries:
203 if isinstance(invalid, tuple):
204 - print invalid[0], invalid[1]
205 + print(invalid[0], invalid[1])
206 else:
207 - print invalid
208 - print ""
209 + print(invalid)
210 + print("")
211
212 if __name__ == "__main__":
213 - print "A list of invalid/obsolete package.mask entries in gentoo-x86, see bug 105016"
214 - print "Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() )
215 - print "Timestamp of tree: %s" % get_timestamp()
216 - print "NOTE: if a package is listed as <category>/<package> <flag> ..."
217 - print " or <category>/<package> then the whole entry is invalid/obsolete."
218 - print "NOTE: if a package is listed as <category>/<package> [ <flag>, ... ] then the listed useflags are invalid."
219 - print ""
220 + print("A list of invalid/obsolete package.mask entries in gentoo repository, see bug 105016")
221 + print("Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() ))
222 + print("Timestamp of tree: %s" % get_timestamp())
223 + print("NOTE: if a package is listed as <category>/<package> <flag> ...")
224 + print(" or <category>/<package> then the whole entry is invalid/obsolete.")
225 + print("NOTE: if a package is listed as <category>/<package> [ <flag>, ... ] then the listed useflags are invalid.")
226 + print("")
227
228 if len(argv) > 1:
229 for _pmask in argv[1:]: