summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/refactor.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-03-19 05:33:36 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-03-19 05:33:36 (GMT)
commit8a5f8ca33b56db9af973d1f34a9b3df5271b56c0 (patch)
tree55b17647085ff8b679f2bea803545884148c66e4 /Lib/lib2to3/refactor.py
parentf733c60d9aea123a46cd41dbe4dedee7aa2f20f3 (diff)
downloadcpython-8a5f8ca33b56db9af973d1f34a9b3df5271b56c0.zip
cpython-8a5f8ca33b56db9af973d1f34a9b3df5271b56c0.tar.gz
cpython-8a5f8ca33b56db9af973d1f34a9b3df5271b56c0.tar.bz2
Run 2to3 on this library.
Diffstat (limited to 'Lib/lib2to3/refactor.py')
-rwxr-xr-xLib/lib2to3/refactor.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index 0961e90..9172e8f 100755
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -63,14 +63,14 @@ def main(args=None):
# Parse command line arguments
options, args = parser.parse_args(args)
if options.list_fixes:
- print "Available transformations for the -f/--fix option:"
+ print("Available transformations for the -f/--fix option:")
for fixname in get_all_fix_names():
- print fixname
+ print(fixname)
if not args:
return 0
if not args:
- print >>sys.stderr, "At least one file or directory argument required."
- print >>sys.stderr, "Use --help to show usage."
+ print("At least one file or directory argument required.", file=sys.stderr)
+ print("Use --help to show usage.", file=sys.stderr)
return 2
# Initialize the refactoring tool
@@ -145,7 +145,7 @@ class RefactoringTool(object):
continue
try:
fixer = fix_class(self.options, self.fixer_log)
- except Exception, err:
+ except Exception as err:
self.log_error("Can't instantiate fixes.fix_%s.%s()",
fix_name, class_name, exc_info=True)
continue
@@ -207,7 +207,7 @@ class RefactoringTool(object):
"""Refactors a file."""
try:
f = open(filename)
- except IOError, err:
+ except IOError as err:
self.log_error("Can't open %s: %s", filename, err)
return
try:
@@ -243,7 +243,7 @@ class RefactoringTool(object):
"""
try:
tree = self.driver.parse_string(data,1)
- except Exception, err:
+ except Exception as err:
self.log_error("Can't parse %s: %s: %s",
name, err.__class__.__name__, err)
return
@@ -331,7 +331,7 @@ class RefactoringTool(object):
if old_text is None:
try:
f = open(filename, "r")
- except IOError, err:
+ except IOError as err:
self.log_error("Can't read %s: %s", filename, err)
return
try:
@@ -351,21 +351,21 @@ class RefactoringTool(object):
if os.path.lexists(backup):
try:
os.remove(backup)
- except os.error, err:
+ except os.error as err:
self.log_message("Can't remove backup %s", backup)
try:
os.rename(filename, backup)
- except os.error, err:
+ except os.error as err:
self.log_message("Can't rename %s to %s", filename, backup)
try:
f = open(filename, "w")
- except os.error, err:
+ except os.error as err:
self.log_error("Can't create %s: %s", filename, err)
return
try:
try:
f.write(new_text)
- except os.error, err:
+ except os.error as err:
self.log_error("Can't write %s: %s", filename, err)
finally:
f.close()
@@ -428,7 +428,7 @@ class RefactoringTool(object):
"""
try:
tree = self.parse_block(block, lineno, indent)
- except Exception, err:
+ except Exception as err:
if self.options.verbose:
for line in block:
self.log_message("Source: %s", line.rstrip("\n"))
@@ -480,7 +480,7 @@ class RefactoringTool(object):
def wrap_toks(self, block, lineno, indent):
"""Wraps a tokenize stream to systematically modify start/end."""
- tokens = tokenize.generate_tokens(self.gen_lines(block, indent).next)
+ tokens = tokenize.generate_tokens(self.gen_lines(block, indent).__next__)
for type, value, (line0, col0), (line1, col1), line_text in tokens:
line0 += lineno - 1
line1 += lineno - 1
@@ -519,7 +519,7 @@ def diff_texts(a, b, filename):
for line in difflib.unified_diff(a, b, filename, filename,
"(original)", "(refactored)",
lineterm=""):
- print line
+ print(line)
if __name__ == "__main__":