From 94f18322db80c252e1872022fff0ae4715726bb4 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sat, 25 Apr 2015 16:03:54 +0200 Subject: [PATCH] Switch to print_function Signed-off-by: Julien Cristau --- britney.py | 21 +++++++++++---------- hints.py | 4 +++- installability/solver.py | 32 +++++++++++++++++--------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/britney.py b/britney.py index 6918cea..6e361ff 100755 --- a/britney.py +++ b/britney.py @@ -179,6 +179,7 @@ does for the generation of the update excuses. * The excuses are written in an HTML file. """ +from __future__ import print_function import os import sys @@ -255,8 +256,8 @@ class Britney(object): if self.options.nuninst_cache: self.__log("Not building the list of non-installable packages, as requested", type="I") if self.options.print_uninst: - print '* summary' - print '\n'.join(map(lambda x: '%4d %s' % (len(nuninst[x]), x), self.options.architectures)) + print('* summary') + print('\n'.join('%4d %s' % (len(nuninst[x]), x) for x in self.options.architectures)) return # read the source and binary packages for the involved distributions @@ -303,8 +304,8 @@ class Britney(object): self.nuninst_arch_report(nuninst, arch) if self.options.print_uninst: - print '* summary' - print '\n'.join(map(lambda x: '%4d %s' % (len(nuninst[x]), x), self.options.architectures)) + print('* summary') + print('\n'.join(map(lambda x: '%4d %s' % (len(nuninst[x]), x), self.options.architectures))) return else: write_nuninst(self.options.noninst_status, nuninst) @@ -396,7 +397,7 @@ class Britney(object): printed only if verbose logging is enabled. """ if self.options.verbose or type in ("E", "W"): - print "%s: [%s] - %s" % (type, time.asctime(), msg) + print("%s: [%s] - %s" % (type, time.asctime(), msg)) def _build_installability_tester(self, archs): """Create the installability tester""" @@ -2600,10 +2601,10 @@ class Britney(object): try: input = raw_input('britney> ').lower().split() except EOFError: - print "" + print("") break except KeyboardInterrupt: - print "" + print("") continue # quit the hint tester if input and input[0] in ('quit', 'exit'): @@ -2822,16 +2823,16 @@ class Britney(object): all[(pkg[SOURCE], pkg[SOURCEVER])].add(p) - print '* %s' % (arch,) + print('* %s' % (arch,)) for (src, ver), pkgs in sorted(all.iteritems()): - print ' %s (%s): %s' % (src, ver, ' '.join(sorted(pkgs))) + print(' %s (%s): %s' % (src, ver, ' '.join(sorted(pkgs)))) print def output_write(self, msg): """Simple wrapper for output writing""" - print msg, + print(msg, end='') self.__output.write(msg) def main(self): diff --git a/hints.py b/hints.py index 7b43cdb..ab47675 100644 --- a/hints.py +++ b/hints.py @@ -12,6 +12,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. +from __future__ import print_function + from migrationitem import MigrationItem class HintCollection(object): @@ -36,7 +38,7 @@ class HintCollection(object): try: self._hints.append(Hint(hint, user)) except AssertionError: - print "Ignoring broken hint %r from %s" % (hint, user) + print("Ignoring broken hint %r from %s" % (hint, user)) class Hint(object): NO_VERSION = [ 'block', 'block-all', 'block-udeb' ] diff --git a/installability/solver.py b/installability/solver.py index 318d5f9..8ca402e 100644 --- a/installability/solver.py +++ b/installability/solver.py @@ -14,6 +14,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. +from __future__ import print_function + from functools import partial import os @@ -106,7 +108,7 @@ class InstallabilitySolver(InstallabilityTester): # "Self-conflicts" => ignore continue if debug_solver and other not in order[key]['before']: - print "N: Conflict induced order: %s before %s" % (key, other) + print("N: Conflict induced order: %s before %s" % (key, other)) order[key]['before'].add(other) order[other]['after'].add(key) @@ -125,7 +127,7 @@ class InstallabilitySolver(InstallabilityTester): # "Self-dependency" => ignore continue if debug_solver and other not in order[key]['after']: - print "N: Removal induced order: %s before %s" % (key, other) + print("N: Removal induced order: %s before %s" % (key, other)) order[key]['after'].add(other) order[other]['before'].add(key) @@ -162,13 +164,13 @@ class InstallabilitySolver(InstallabilityTester): for other in (other_adds - other_rms): if debug_solver and other != key and other not in order[key]['after']: - print "N: Dependency induced order (add): %s before %s" % (key, other) + print("N: Dependency induced order (add): %s before %s" % (key, other)) order[key]['after'].add(other) order[other]['before'].add(key) for other in (other_rms - other_adds): if debug_solver and other != key and other not in order[key]['before']: - print "N: Dependency induced order (remove): %s before %s" % (key, other) + print("N: Dependency induced order (remove): %s before %s" % (key, other)) order[key]['before'].add(other) order[other]['after'].add(key) @@ -208,7 +210,7 @@ class InstallabilitySolver(InstallabilityTester): merged[n] = scc_id del order[n] if debug_solver: - print "N: SCC: %s -- %s" % (scc_id, str(sorted(com))) + print("N: SCC: %s -- %s" % (scc_id, str(sorted(com)))) for com in comps: node = com[0] @@ -223,27 +225,27 @@ class InstallabilitySolver(InstallabilityTester): if debug_solver: - print "N: -- PARTIAL ORDER --" + print("N: -- PARTIAL ORDER --") for com in sorted(order): if debug_solver and order[com]['before']: - print "N: %s <= %s" % (com, str(sorted(order[com]['before']))) + print("N: %s <= %s" % (com, str(sorted(order[com]['before'])))) if not order[com]['after']: # This component can be scheduled immediately, add it # to "check" check.add(com) elif debug_solver: - print "N: %s >= %s" % (com, str(sorted(order[com]['after']))) + print("N: %s >= %s" % (com, str(sorted(order[com]['after'])))) if debug_solver: - print "N: -- END PARTIAL ORDER --" - print "N: -- LINEARIZED ORDER --" + print("N: -- END PARTIAL ORDER --") + print("N: -- LINEARIZED ORDER --") for cur in iter_except(check.pop, KeyError): if order[cur]['after'] <= emitted: # This item is ready to be emitted right now if debug_solver: - print "N: %s -- %s" % (cur, sorted(scc[cur])) + print("N: %s -- %s" % (cur, sorted(scc[cur]))) emitted.add(cur) result.append([key2item[x] for x in scc[cur]]) if order[cur]['before']: @@ -254,7 +256,7 @@ class InstallabilitySolver(InstallabilityTester): check.update(order[cur]['before'] - emitted) if debug_solver: - print "N: -- END LINEARIZED ORDER --" + print("N: -- END LINEARIZED ORDER --") return result @@ -301,8 +303,8 @@ class InstallabilitySolver(InstallabilityTester): return result def _dump_groups(self, groups): - print "N: === Groups ===" + print("N: === Groups ===") for (item, adds, rms) in groups: - print "N: %s => A: %s, R: %s" % (str(item), str(adds), str(rms)) - print "N: === END Groups ===" + print("N: %s => A: %s, R: %s" % (str(item), str(adds), str(rms))) + print("N: === END Groups ===")