From 15b8a5bbdf3fb81edc6eac707bd2bd78d54394cf Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 20 Sep 2009 11:08:30 +0000 Subject: Update syntax of calls to print() for compatibility with Python 3. (2to3-3.1 -f print -nw ${FILES}) svn path=/main/trunk/; revision=14290 --- bin/archive-conf | 4 +- bin/check-implicit-pointer-usage.py | 4 +- bin/clean_locks | 24 +- bin/dispatch-conf | 55 ++- bin/ebuild | 18 +- bin/ebuild-helpers/dohtml | 32 +- bin/emaint | 14 +- bin/env-update | 10 +- bin/fixpackages | 6 +- bin/portageq | 86 ++--- bin/quickpkg | 6 +- bin/regenworld | 14 +- bin/repoman | 164 ++++---- pym/_emerge/Scheduler.py | 10 +- pym/_emerge/actions.py | 295 ++++++++------- pym/_emerge/countdown.py | 6 +- pym/_emerge/depgraph.py | 114 +++--- pym/_emerge/emergelog.py | 2 +- pym/_emerge/help.py | 724 ++++++++++++++++++------------------ pym/_emerge/main.py | 52 +-- pym/_emerge/search.py | 24 +- pym/_emerge/unmerge.py | 58 +-- pym/_emerge/userquery.py | 6 +- pym/portage/__init__.py | 36 +- pym/portage/cache/sql_template.py | 2 +- pym/portage/cache/util.py | 10 +- pym/portage/cvstree.py | 32 +- pym/portage/dbapi/bintree.py | 2 +- pym/portage/dbapi/porttree.py | 4 +- pym/portage/dbapi/vartree.py | 14 +- pym/portage/dispatch_conf.py | 22 +- pym/portage/eclass_cache.py | 4 +- pym/portage/elog/mod_echo.py | 4 +- pym/portage/localization.py | 6 +- pym/portage/mail.py | 2 +- pym/portage/sets/__init__.py | 8 +- pym/portage/sets/libs.py | 6 +- pym/portage/versions.py | 8 +- pym/portage/xpak.py | 2 +- pym/repoman/utilities.py | 2 +- 40 files changed, 945 insertions(+), 947 deletions(-) diff --git a/bin/archive-conf b/bin/archive-conf index 680a99cb5..227bcece2 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -73,7 +73,7 @@ def archive_conf(): try: contents = open(file, "r") except IOError as e: - print >> sys.stderr, 'archive-conf: Unable to open %s: %s' % (file, e) + print('archive-conf: Unable to open %s: %s' % (file, e), file=sys.stderr) sys.exit(1) lines = contents.readlines() for line in lines: @@ -106,4 +106,4 @@ def archive_conf(): if len(sys.argv) > 1: archive_conf() else: - print >> sys.stderr, 'Usage: archive-conf /CONFIG/FILE [/CONFIG/FILE...]' + print('Usage: archive-conf /CONFIG/FILE [/CONFIG/FILE...]', file=sys.stderr) diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py index c462329e4..c50424b83 100755 --- a/bin/check-implicit-pointer-usage.py +++ b/bin/check-implicit-pointer-usage.py @@ -51,6 +51,6 @@ while True: pointer_linenum = int(m.group(2)) if (last_implicit_filename == pointer_filename and last_implicit_linenum == pointer_linenum): - print "Function `%s' implicitly converted to pointer at " \ + print(("Function `%s' implicitly converted to pointer at " \ "%s:%d" % (last_implicit_func, last_implicit_filename, - last_implicit_linenum) + last_implicit_linenum))) diff --git a/bin/clean_locks b/bin/clean_locks index ec593a311..eaeedda33 100755 --- a/bin/clean_locks +++ b/bin/clean_locks @@ -15,15 +15,15 @@ from portage import os if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: import portage - print - print "You must specify directories with hardlink-locks to clean." - print "You may optionally specify --force, which will remove all" - print "of the locks, even if we can't establish if they are in use." - print "Please attempt cleaning without force first." - print - print "%s %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"]) - print "%s --force %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"]) - print + print() + print("You must specify directories with hardlink-locks to clean.") + print("You may optionally specify --force, which will remove all") + print("of the locks, even if we can't establish if they are in use.") + print("Please attempt cleaning without force first.") + print() + print("%s %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"])) + print("%s --force %s/.locks" % (sys.argv[0], portage.settings["DISTDIR"])) + print() sys.exit(1) force = False @@ -35,12 +35,12 @@ for x in sys.argv[1:]: continue try: for y in portage.locks.hardlock_cleanup(x, remove_all_locks=force): - print y - print + print(y) + print() except OSError as e: if e.errno in (errno.ENOENT, errno.ENOTDIR): - print "!!! %s is not a directory or does not exist" % x + print("!!! %s is not a directory or does not exist" % x) else: raise sys.exit(e.errno) diff --git a/bin/dispatch-conf b/bin/dispatch-conf index d0309701e..2ef55a908 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -104,9 +104,8 @@ class dispatch: if self.options['use-rcs'] == 'yes': for rcs_util in ("rcs", "ci", "co", "rcsmerge"): if not find_binary(rcs_util): - print >> sys.stderr, \ - 'dispatch-conf: Error finding all RCS utils and " + \ - "use-rcs=yes in config; fatal' + print('dispatch-conf: Error finding all RCS utils and " + \ + "use-rcs=yes in config; fatal', file=sys.stderr) return False @@ -225,9 +224,9 @@ class dispatch: cmd = self.options['diff'] % (conf['current'], newconf) spawn_shell(cmd) - print - print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current']) - print '>> q quit, h help, n next, e edit-new, z zap-new, u use-new\n m merge, t toggle-merge, l look-merge: ', + print() + print('>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])) + print('>> q quit, h help, n next, e edit-new, z zap-new, u use-new\n m merge, t toggle-merge, l look-merge: ', end=' ') # In some cases getch() will return some spurious characters # that do not represent valid input. If we don't validate the @@ -255,10 +254,10 @@ class dispatch: break elif c == 'm': merged = SCRATCH_DIR+"/"+os.path.basename(conf['current']) - print + print() ret = os.system (self.options['merge'] % (merged, conf ['current'], newconf)) if ret: - print "Failure running 'merge' command" + print("Failure running 'merge' command") continue shutil.copyfile(merged, mrgconf) os.remove(merged) @@ -292,12 +291,12 @@ class dispatch: raise AssertionError("Invalid Input: %s" % c) if auto_zapped: - print - print " One or more updates are frozen and have been automatically zapped:" - print + print() + print(" One or more updates are frozen and have been automatically zapped:") + print() for frozen in auto_zapped: - print " * '%s'" % frozen - print + print(" * '%s'" % frozen) + print() def replace (self, newconf, curconf): """Replace current config with the new/merged version. Also logs @@ -306,8 +305,8 @@ class dispatch: try: os.rename(newconf, curconf) except (IOError, os.error) as why: - print >> sys.stderr, 'dispatch-conf: Error renaming %s to %s: %s; fatal' % \ - (newconf, curconf, str(why)) + print('dispatch-conf: Error renaming %s to %s: %s; fatal' % \ + (newconf, curconf, str(why)), file=sys.stderr) def post_process(self, curconf): @@ -354,19 +353,19 @@ class dispatch: def do_help (self): - print; print - - print ' u -- update current config with new config and continue' - print ' z -- zap (delete) new config and continue' - print ' n -- skip to next config, leave all intact' - print ' e -- edit new config' - print ' m -- interactively merge current and new configs' - print ' l -- look at diff between pre-merged and merged configs' - print ' t -- toggle new config between merged and pre-merged state' - print ' h -- this screen' - print ' q -- quit' - - print; print 'press any key to return to diff...', + print(); print + + print(' u -- update current config with new config and continue') + print(' z -- zap (delete) new config and continue') + print(' n -- skip to next config, leave all intact') + print(' e -- edit new config') + print(' m -- interactively merge current and new configs') + print(' l -- look at diff between pre-merged and merged configs') + print(' t -- toggle new config between merged and pre-merged state') + print(' h -- this screen') + print(' q -- quit') + + print(); print('press any key to return to diff...', end=' ') getch () diff --git a/bin/ebuild b/bin/ebuild index e41764b8e..fa7c3d536 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -51,7 +51,7 @@ if len(pargs) < 2: parser.error("missing required args") if "merge" in pargs: - print "Disabling noauto in features... merge disables it. (qmerge doesn't)" + print("Disabling noauto in features... merge disables it. (qmerge doesn't)") os.environ["FEATURES"] = os.environ.get("FEATURES", "") + " -noauto" os.environ["PORTAGE_CALLER"]="ebuild" @@ -117,7 +117,7 @@ ebuild = os.path.join(ebuild_portdir, *ebuild.split(os.path.sep)[-3:]) if ebuild_portdir not in portage.portdb.porttrees: os.environ["PORTDIR_OVERLAY"] = \ os.environ.get("PORTDIR_OVERLAY","") + " " + ebuild_portdir - print "Appending %s to PORTDIR_OVERLAY..." % ebuild_portdir + print("Appending %s to PORTDIR_OVERLAY..." % ebuild_portdir) portage.close_portdbapi_caches() reload(portage) del portage.portdb.porttrees[1:] @@ -125,14 +125,14 @@ if ebuild_portdir != portage.portdb.porttree_root: portage.portdb.porttrees.append(ebuild_portdir) if not os.path.exists(ebuild): - print "'%s' does not exist." % ebuild + print("'%s' does not exist." % ebuild) sys.exit(1) ebuild_split = ebuild.split("/") cpv = "%s/%s" % (ebuild_split[-3], pf) if not portage.catpkgsplit(cpv): - print "!!! %s does not follow correct package syntax." % (cpv) + print("!!! %s does not follow correct package syntax." % (cpv)) sys.exit(1) if ebuild.startswith(os.path.join(portage.root, portage.const.VDB_PATH)): @@ -141,7 +141,7 @@ if ebuild.startswith(os.path.join(portage.root, portage.const.VDB_PATH)): portage_ebuild = portage.db[portage.root][mytree].dbapi.findname(cpv) if os.path.realpath(portage_ebuild) != ebuild: - print "!!! Portage seems to think that %s is at %s" % (cpv, portage_ebuild) + print("!!! Portage seems to think that %s is at %s" % (cpv, portage_ebuild)) sys.exit(1) else: @@ -150,11 +150,11 @@ else: portage_ebuild = portage.portdb.findname(cpv) if not portage_ebuild or portage_ebuild != ebuild: - print "!!! %s does not seem to have a valid PORTDIR structure." % ebuild + print("!!! %s does not seem to have a valid PORTDIR structure." % ebuild) sys.exit(1) if len(pargs) > 1 and "config" in pargs: - print "config must be called on it's own, not combined with any other phase" + print("config must be called on it's own, not combined with any other phase") sys.exit(1) def discard_digests(myebuild, mysettings, mydbapi): @@ -250,7 +250,7 @@ for arg in pargs: a = portage.doebuild(ebuild, arg, portage.root, tmpsettings, debug=debug, tree=mytree) except KeyboardInterrupt: - print "Interrupted." + print("Interrupted.") a = 1 except KeyError: # aux_get error @@ -269,7 +269,7 @@ for arg in pargs: portage.writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1) a = 1 if a == None: - print "Could not run the required binary?" + print("Could not run the required binary?") a = 127 if a: sys.exit(a) diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml index be3716d8e..f672a9a0c 100755 --- a/bin/ebuild-helpers/dohtml +++ b/bin/ebuild-helpers/dohtml @@ -106,19 +106,19 @@ class OptionsClass: def print_help(): opts = OptionsClass() - print "dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]" - print " [-r] [-V] [file ...]" - print - print " -a Set the list of allowed to those that are specified." - print " Default:", ",".join(opts.allowed_exts) - print " -A Extend the list of allowed file types." - print " -f Set list of allowed extensionless file names." - print " -x Set directories to be excluded from recursion." - print " Default:", ",".join(opts.disallowed_dirs) - print " -p Set a document prefix for installed files (empty by default)." - print " -r Install files and directories recursively." - print " -V Be verbose." - print + print("dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]") + print(" [-r] [-V] [file ...]") + print() + print(" -a Set the list of allowed to those that are specified.") + print(" Default:", ",".join(opts.allowed_exts)) + print(" -A Extend the list of allowed file types.") + print(" -f Set list of allowed extensionless file names.") + print(" -x Set directories to be excluded from recursion.") + print(" Default:", ",".join(opts.disallowed_dirs)) + print(" -p Set a document prefix for installed files (empty by default).") + print(" -r Install files and directories recursively.") + print(" -V Be verbose.") + print() def parse_args(): options = OptionsClass() @@ -163,9 +163,9 @@ def main(): (options, args) = parse_args() if options.verbose: - print "Allowed extensions:", options.allowed_exts - print "Document prefix : '" + options.doc_prefix + "'" - print "Allowed files :", options.allowed_files + print("Allowed extensions:", options.allowed_exts) + print("Document prefix : '" + options.doc_prefix + "'") + print("Allowed files :", options.allowed_files) success = False diff --git a/bin/emaint b/bin/emaint index ac791c14c..2dd6d1407 100755 --- a/bin/emaint +++ b/bin/emaint @@ -518,7 +518,7 @@ def emaint_main(myargv): if parser.action: action = parser.action else: - print "Defaulting to --check" + print("Defaulting to --check") action = "-c/--check" if args[0] == "all": @@ -536,7 +536,7 @@ def emaint_main(myargv): isatty = sys.stdout.isatty() for task in tasks: - print status % task.name() + print(status % task.name()) inst = task() onProgress = None if isatty: @@ -554,14 +554,14 @@ def emaint_main(myargv): if isatty: # make sure the final progress is displayed progressHandler.display() - print + print() signal.signal(signal.SIGWINCH, signal.SIG_DFL) if result: - print - print "\n".join(result) - print "\n" + print() + print("\n".join(result)) + print("\n") - print "Finished" + print("Finished") if __name__ == "__main__": emaint_main(sys.argv[1:]) diff --git a/bin/env-update b/bin/env-update index 3fa21c7fa..912602f7b 100755 --- a/bin/env-update +++ b/bin/env-update @@ -6,9 +6,9 @@ import sys, errno def usage(status): - print "Usage: env-update [--no-ldconfig]" - print "" - print "See the env-update(1) man page for more info" + print("Usage: env-update [--no-ldconfig]") + print("") + print("See the env-update(1) man page for more info") sys.exit(status) if "-h" in sys.argv or "--help" in sys.argv: @@ -20,7 +20,7 @@ if "--no-ldconfig" in sys.argv: sys.argv.pop(sys.argv.index("--no-ldconfig")) if len(sys.argv) > 1: - print "!!! Invalid command line options!\n" + print("!!! Invalid command line options!\n") usage(1) try: @@ -33,7 +33,7 @@ try: portage.env_update(makelinks) except IOError as e: if e.errno == errno.EACCES: - print "env-update: Need superuser access" + print("env-update: Need superuser access") sys.exit(1) else: raise diff --git a/bin/fixpackages b/bin/fixpackages index dc7a5d24f..a85277f0e 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -27,6 +27,6 @@ except (OSError, ValueError) as e: portage._global_updates(mytrees, mtimedb["updates"]) -print -print "Done." -print +print() +print("Done.") +print() diff --git a/bin/portageq b/bin/portageq index 04c0ca034..0e26be01c 100755 --- a/bin/portageq +++ b/bin/portageq @@ -70,7 +70,7 @@ def has_version(argv): Return code 0 if it's available, 1 otherwise. """ if (len(argv) < 2): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) if atom_validate_strict and not portage.isvalidatom(argv[1]): portage.writemsg("ERROR: Invalid atom: '%s'\n" % argv[1], @@ -92,7 +92,7 @@ def best_version(argv): Returns category/package-version (without .ebuild). """ if (len(argv) < 2): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) if atom_validate_strict and not portage.isvalidatom(argv[1]): portage.writemsg("ERROR: Invalid atom: '%s'\n" % argv[1], @@ -100,7 +100,7 @@ def best_version(argv): return 2 try: mylist=portage.db[argv[0]]["vartree"].dbapi.match(argv[1]) - print portage.best(mylist) + print(portage.best(mylist)) except KeyError: sys.exit(1) best_version.uses_root = True @@ -111,12 +111,12 @@ def mass_best_version(argv): Returns category/package-version (without .ebuild). """ if (len(argv) < 2): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) try: for pack in argv[1:]: mylist=portage.db[argv[0]]["vartree"].dbapi.match(pack) - print pack+":"+portage.best(mylist) + print(pack+":"+portage.best(mylist)) except KeyError: sys.exit(1) mass_best_version.uses_root = True @@ -126,7 +126,7 @@ def metadata(argv): Returns metadata values for the specified package. """ if (len(argv) < 4): - print >> sys.stderr, "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!", file=sys.stderr) sys.exit(2) root, pkgtype, pkgspec = argv[0:3] @@ -136,7 +136,7 @@ def metadata(argv): "binary":"bintree", "installed":"vartree"} if pkgtype not in type_map: - print >> sys.stderr, "Unrecognized package type: '%s'" % pkgtype + print("Unrecognized package type: '%s'" % pkgtype, file=sys.stderr) sys.exit(1) trees = portage.db if os.path.realpath(root) == os.path.realpath(portage.settings["ROOT"]): @@ -146,7 +146,7 @@ def metadata(argv): pkgspec, metakeys) writemsg_stdout(''.join('%s\n' % x for x in values), noiselevel=-1) except KeyError: - print >> sys.stderr, "Package not found: '%s'" % pkgspec + print("Package not found: '%s'" % pkgspec, file=sys.stderr) sys.exit(1) metadata.uses_root = True @@ -158,7 +158,7 @@ def contents(argv): . """ if len(argv) != 2: - print "ERROR: expected 2 parameters, got %d!" % len(argv) + print("ERROR: expected 2 parameters, got %d!" % len(argv)) return 2 root, cpv = argv @@ -350,13 +350,13 @@ def best_visible(argv): Returns category/package-version (without .ebuild). """ if (len(argv) < 2): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) try: mylist=portage.db[argv[0]]["porttree"].dbapi.match(argv[1]) visible=portage.best(mylist) if visible: - print visible + print(visible) sys.exit(0) else: sys.exit(1) @@ -370,12 +370,12 @@ def mass_best_visible(argv): Returns category/package-version (without .ebuild). """ if (len(argv) < 2): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) try: for pack in argv[1:]: mylist=portage.db[argv[0]]["porttree"].dbapi.match(pack) - print pack+":"+portage.best(mylist) + print(pack+":"+portage.best(mylist)) except KeyError: sys.exit(1) mass_best_visible.uses_root = True @@ -386,13 +386,13 @@ def all_best_visible(argv): Returns all best_visible packages (without .ebuild). """ if (len(argv) < 1): - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") #print portage.db[argv[0]]["porttree"].dbapi.cp_all() for pkg in portage.db[argv[0]]["porttree"].dbapi.cp_all(): mybest=portage.best(portage.db[argv[0]]["porttree"].dbapi.match(pkg)) if mybest: - print mybest + print(mybest) all_best_visible.uses_root = True @@ -403,7 +403,7 @@ def match(argv): be listed. """ if len(argv) != 2: - print "ERROR: expected 2 parameters, got %d!" % len(argv) + print("ERROR: expected 2 parameters, got %d!" % len(argv)) sys.exit(2) root, atom = argv if atom: @@ -416,7 +416,7 @@ def match(argv): results = portage.db[root]["vartree"].dbapi.cpv_all() results.sort() for cpv in results: - print cpv + print(cpv) match.uses_root = True @@ -434,49 +434,49 @@ def gentoo_mirrors(argv): """ Returns the mirrors set to use in the portage configuration. """ - print portage.settings["GENTOO_MIRRORS"] + print(portage.settings["GENTOO_MIRRORS"]) def portdir(argv): """ Returns the PORTDIR path. """ - print portage.settings["PORTDIR"] + print(portage.settings["PORTDIR"]) def config_protect(argv): """ Returns the CONFIG_PROTECT paths. """ - print portage.settings["CONFIG_PROTECT"] + print(portage.settings["CONFIG_PROTECT"]) def config_protect_mask(argv): """ Returns the CONFIG_PROTECT_MASK paths. """ - print portage.settings["CONFIG_PROTECT_MASK"] + print(portage.settings["CONFIG_PROTECT_MASK"]) def portdir_overlay(argv): """ Returns the PORTDIR_OVERLAY path. """ - print portage.settings["PORTDIR_OVERLAY"] + print(portage.settings["PORTDIR_OVERLAY"]) def pkgdir(argv): """ Returns the PKGDIR path. """ - print portage.settings["PKGDIR"] + print(portage.settings["PKGDIR"]) def distdir(argv): """ Returns the DISTDIR path. """ - print portage.settings["DISTDIR"] + print(portage.settings["DISTDIR"]) def envvar(argv): @@ -489,33 +489,33 @@ def envvar(argv): argv.pop(argv.index("-v")) if len(argv) == 0: - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) for arg in argv: if verbose: - print arg +"='"+ portage.settings[arg] +"'" + print(arg +"='"+ portage.settings[arg] +"'") else: - print portage.settings[arg] + print(portage.settings[arg]) def get_repos(argv): """ Returns all repos with names (repo_name file) argv[0] = $ROOT """ if len(argv) < 1: - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) - print " ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories()) + print(" ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories())) def get_repo_path(argv): """ + Returns the path to the repo named argv[1], argv[0] = $ROOT """ if len(argv) < 2: - print "ERROR: insufficient parameters!" + print("ERROR: insufficient parameters!") sys.exit(2) for arg in argv[1:]: - print portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(arg) + print(portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(arg)) def list_preserved_libs(argv): """ @@ -525,7 +525,7 @@ def list_preserved_libs(argv): """ if len(argv) != 1: - print "ERROR: wrong number of arguments" + print("ERROR: wrong number of arguments") sys.exit(2) mylibs = portage.db[argv[0]]["vartree"].dbapi.plib_registry.getPreservedLibs() rValue = 0 @@ -546,11 +546,11 @@ list_preserved_libs.uses_root = True # def usage(argv): - print ">>> Portage information query tool" - print ">>> $Id$" - print ">>> Usage: portageq [