commit:     97de79100b7e0b85c93c6d8b48eb3fbae4a7b516
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 17 13:14:25 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jul 17 13:14:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=97de7910

mask_check.py: Have print statements work in Python 3

Fixes alerts from cron

 package.mask/mask_check.py | 90 +++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
index 92af0c6..77b493a 100755
--- a/package.mask/mask_check.py
+++ b/package.mask/mask_check.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # python mask_check.py $(find /usr/portage/profiles -type f -name '*.mask' 
-not -regex '.*/prefix/.*')
@@ -40,9 +40,9 @@ def pkgcmp_atom(pkgdir, pkg):
 
        revre = re.compile( ("^" + re.escape(ppkg) + "(-r\d+)?.ebuild$") )
 
-#      print "DBG: checking for %s" % pkg
-#      print "DBG: Got %i ebuilds:" % len(ebuilds)
-#      print ebuilds
+#      print("DBG: checking for %s" % pkg)
+#      print("DBG: Got %i ebuilds:" % len(ebuilds))
+#      print(ebuilds)
 
        for ebuild in ebuilds:
                # workaround? for - prefix
@@ -52,24 +52,24 @@ def pkgcmp_atom(pkgdir, pkg):
                if pkg.startswith( ("=", "~") ):
                        if pkg.startswith("~"):
                                if revre.match(ebuild):
-#                                      print "DBG: revmatch '%s' '%s'" % (pkg, 
ebuild)
+#                                      print("DBG: revmatch '%s' '%s'" % (pkg, 
ebuild))
                                        return 1
                                else:
-#                                      print "DBG: revmatch continue"
+#                                      print("DBG: revmatch continue")
                                        continue
                        if pkg.endswith("*"):
                                if ebuild.startswith(ppkg):
-#                                      print "DBG: startswith '%s' '%s'" % 
(pkg, ebuild)
+#                                      print("DBG: startswith '%s' '%s'" % 
(pkg, ebuild))
                                        return 1
                                else:
-#                                      print "DBG: startswith continue"
+#                                      print("DBG: startswith continue")
                                        continue
                        else:
                                if ebuild == (ppkg + ".ebuild"):
-#                                      print "DBG: '%s' == '%s'" % (ppkg, ppkg)
+#                                      print("DBG: '%s' == '%s'" % (ppkg, 
ppkg))
                                        return 1
                                else:
-#                                      print "DBG: == continue"
+#                                      print("DBG: == continue")
                                        continue
 
                if pkg.startswith( (">=", ">", "<=", "<") ):
@@ -86,38 +86,38 @@ def pkgcmp_atom(pkgdir, pkg):
                        if ourpkg[2] != "r0":
                                ourpkgv = ourpkgv + "-" + ourpkg[2]
 
-#                      print "MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 
'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv))
+#                      print("MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 
'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv)))
 
                        if pkg.startswith(">="):
                                if vercmp(mypkgv, ourpkgv) <= 0:
-#                                      print "HIT: '%s' >= '%s'" % (ourpkg, 
mypkg)
+#                                      print("HIT: '%s' >= '%s'" % (ourpkg, 
mypkg))
                                        return 1
                                else:
-#                                      print ">= continue"
+#                                      print(">= continue")
                                        continue
                        if pkg.startswith(">") and not pkg.startswith(">="):
                                if vercmp(mypkgv, ourpkgv) < 0:
-#                                      print "HIT: '%s' > '%s'" % (ourpkg, 
mypkg)
+#                                      print("HIT: '%s' > '%s'" % (ourpkg, 
mypkg))
                                        return 1
                                else:
-#                                      print "> continue"
+#                                      print("> continue")
                                        continue
                        if pkg.startswith("<="):
                                if vercmp(mypkgv, ourpkgv) >= 0:
-#                                      print "HIT: '%s' <= '%s'" % (ourpkg, 
mypkg)
+#                                      print("HIT: '%s' <= '%s'" % (ourpkg, 
mypkg))
                                        return 1
                                else:
-#                                      print "<= continue"
+#                                      print("<= continue"
                                        continue
                        if pkg.startswith("<") and not pkg.startswith("<="):
                                if vercmp(mypkgv, ourpkgv) > 0:
-#                                      print "HIT: '%s' < '%s'" % (ourpkg, 
mypkg)
+#                                      print("HIT: '%s' < '%s'" % (ourpkg, 
mypkg))
                                        return 1
                                else:
-#                                      print "< continue"
+#                                      print("< continue")
                                        continue
 
-#      print "Nothing found... '%s' is invalid" % pkg
+#      print("Nothing found... '%s' is invalid" % pkg)
        return 0
 
 def check_locuse(portdir, pkg, invalid):
@@ -196,26 +196,26 @@ def check_use(portdir, line):
                        else:
                                _flag = "%s_%s" % 
(basename(usedesc_f).replace(".desc", ""), _flag)
                                globuse.append(_flag)
-#                              print "GLOB: ", _flag
+#                              print("GLOB: ", _flag)
 
                usedesc_fd.close()
 
-#      print globuse
+#      print(globuse)
 #      exit(1)
 
        for flag in useflags:
                if not flag in globuse:
                        # nothing found
                        invalid.append(flag)
-#                      print "Add useflag %s" %flag
+#                      print("Add useflag %s" %flag)
 
        # check metadata.xml
        if invalid:
                invalid = check_locuse(portdir, pkg, invalid)
 
 
-#      print portdir, pkg, useflags
-#      print globuse
+#      print(portdir, pkg, useflags)
+#      print(globuse)
 
        if invalid:
                return (pkg, invalid)
@@ -224,24 +224,24 @@ def check_use(portdir, line):
 
 # <cat>/<pkg> <use> ...
 def check_pkg(portdir, line):
-#      print "PKGM1:", line
+#      print("PKGM1:", line)
        pkgm = line.split(" ")[0]
-#      print "PKGM2:", pkgm
-#      print "DBG:", line.split(" ")
+#      print("PKGM2:", pkgm)
+#      print("DBG:", line.split(" "))
 
        if pkgm.startswith("-"):
                pkgm = pkgm[1:]
 
        if pkgm.startswith(OPERATORS):
                pkg = []
-#              print "DBG1: %s" % pkgm
+#              print("DBG1: %s" % pkgm)
                plain_pkg = strip_atoms(pkgm)
-#              print "DBG2: %s" % plain_pkg
+#              print("DBG2: %s" % plain_pkg)
 
                pkg = pkgsplit(plain_pkg)
                if not pkg:
-                       print >> stderr, "Error encountered during pkgsplit(), 
please contact [email protected] including the whole output!"
-                       print >> stderr, "1: %s; 2: %s" % (pkgm, plain_pkg)
+                       print("Error encountered during pkgsplit(), please 
contact [email protected] including the whole output!", file=stderr)
+                       print("1: %s; 2: %s" % (pkgm, plain_pkg), file=stderr)
                        return 0
 
                plain_pkg = strip_atoms(pkg[0])
@@ -305,33 +305,33 @@ def obsolete_pmask(portdir = None, package_mask=None):
 
                # don't check useflags with check_pkg
                if line.find("/") != -1 and not check_pkg(portdir, line):
-#                      print "Add whole entry: '%s'" % line
+#                      print("Add whole entry: '%s'" % line)
                        invalid_entries.append(line)
                else:
                        invalid_use = check_use(portdir, line)
                        if invalid_use:
-#                              print "Add useflags: '%s %s'" % 
(invalid_use[0], invalid_use[1])
+#                              print("Add useflags: '%s %s'" % 
(invalid_use[0], invalid_use[1]))
                                invalid_entries.append(invalid_use)
 
        pmask.close()
 
        if invalid_entries:
-               print "Found %i invalid/obsolete entries in %s:" % 
(len(invalid_entries), package_mask)
+               print("Found %i invalid/obsolete entries in %s:" % 
(len(invalid_entries), package_mask))
                for invalid in invalid_entries:
                        if isinstance(invalid, tuple):
-                               print invalid[0], invalid[1]
+                               print(invalid[0], invalid[1])
                        else:
-                               print invalid
-               print ""
+                               print(invalid)
+               print("")
 
 if __name__ == "__main__":
-       print "A list of invalid/obsolete package.mask entries in gentoo-x86, 
see bug 105016"
-       print "Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", 
gmtime() )
-       print "Timestamp of tree: %s" % get_timestamp()
-       print "NOTE: if a package is listed as <category>/<package> <flag> ..."
-       print " or <category>/<package> then the whole entry is 
invalid/obsolete."
-       print "NOTE: if a package is listed as <category>/<package> [ <flag>, 
... ] then the listed useflags are invalid."
-       print ""
+       print("A list of invalid/obsolete package.mask entries in gentoo 
repository, see bug 105016")
+       print("Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", 
gmtime() ))
+       print("Timestamp of tree: %s" % get_timestamp())
+       print("NOTE: if a package is listed as <category>/<package> <flag> ...")
+       print(" or <category>/<package> then the whole entry is 
invalid/obsolete.")
+       print("NOTE: if a package is listed as <category>/<package> [ <flag>, 
... ] then the listed useflags are invalid.")
+       print("")
 
        if len(argv) > 1:
                for _pmask in argv[1:]:

Reply via email to