summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/main.py')
-rw-r--r--Lib/lib2to3/main.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py
index c51626b..ad0625e 100644
--- a/Lib/lib2to3/main.py
+++ b/Lib/lib2to3/main.py
@@ -2,7 +2,7 @@
Main program for 2to3.
"""
-from __future__ import with_statement, print_function
+from __future__ import with_statement
import sys
import os
@@ -80,7 +80,7 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
filename += self._append_suffix
if orig_filename != filename:
output_dir = os.path.dirname(filename)
- if not os.path.isdir(output_dir) and output_dir:
+ if not os.path.isdir(output_dir):
os.makedirs(output_dir)
self.log_message('Writing converted %s to %s.', orig_filename,
filename)
@@ -90,11 +90,11 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
if os.path.lexists(backup):
try:
os.remove(backup)
- except OSError:
+ except os.error, err:
self.log_message("Can't remove backup %s", backup)
try:
os.rename(filename, backup)
- except OSError:
+ except os.error, err:
self.log_message("Can't rename %s to %s", filename, backup)
# Actually write the new file
write = super(StdoutRefactoringTool, self).write_file
@@ -116,18 +116,19 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
if self.output_lock is not None:
with self.output_lock:
for line in diff_lines:
- print(line)
+ print line
sys.stdout.flush()
else:
for line in diff_lines:
- print(line)
+ print line
except UnicodeEncodeError:
warn("couldn't encode %s's diff for your terminal" %
(filename,))
return
+
def warn(msg):
- print("WARNING: %s" % (msg,), file=sys.stderr)
+ print >> sys.stderr, "WARNING: %s" % (msg,)
def main(fixer_pkg, args=None):
@@ -194,19 +195,19 @@ def main(fixer_pkg, args=None):
if not options.write and options.nobackups:
parser.error("Can't use -n without -w")
if options.list_fixes:
- print("Available transformations for the -f/--fix option:")
+ print "Available transformations for the -f/--fix option:"
for fixname in refactor.get_all_fix_names(fixer_pkg):
- print(fixname)
+ print fixname
if not args:
return 0
if not args:
- print("At least one file or directory argument required.", file=sys.stderr)
- print("Use --help to show usage.", file=sys.stderr)
+ print >> sys.stderr, "At least one file or directory argument required."
+ print >> sys.stderr, "Use --help to show usage."
return 2
if "-" in args:
refactor_stdin = True
if options.write:
- print("Can't write to stdin.", file=sys.stderr)
+ print >> sys.stderr, "Can't write to stdin."
return 2
if options.print_function:
flags["print_function"] = True
@@ -259,8 +260,8 @@ def main(fixer_pkg, args=None):
options.processes)
except refactor.MultiprocessingUnsupported:
assert options.processes > 1
- print("Sorry, -j isn't supported on this platform.",
- file=sys.stderr)
+ print >> sys.stderr, "Sorry, -j isn't " \
+ "supported on this platform."
return 1
rt.summarize()