simple py3 changes
diff --git a/devtools/antglob.py b/devtools/antglob.py
index 30837b5..8b7b4ca 100644
--- a/devtools/antglob.py
+++ b/devtools/antglob.py
@@ -2,6 +2,7 @@
# encoding: utf-8
# Baptiste Lepilleur, 2009
+from __future__ import print_function
from dircache import listdir
import re
import fnmatch
@@ -190,12 +191,12 @@
test_cases.append( (ant_pattern, local_path(accepted_matches), local_path( rejected_matches )) )
for ant_pattern, accepted_matches, rejected_matches in test_cases:
rex = ant_pattern_to_re( ant_pattern )
- print 'ant_pattern:', ant_pattern, ' => ', rex.pattern
+ print('ant_pattern:', ant_pattern, ' => ', rex.pattern)
for accepted_match in accepted_matches:
- print 'Accepted?:', accepted_match
- self.assert_( rex.match( accepted_match ) is not None )
+ print('Accepted?:', accepted_match)
+ self.assertTrue( rex.match( accepted_match ) is not None )
for rejected_match in rejected_matches:
- print 'Rejected?:', rejected_match
- self.assert_( rex.match( rejected_match ) is None )
+ print('Rejected?:', rejected_match)
+ self.assertTrue( rex.match( rejected_match ) is None )
unittest.main()
diff --git a/devtools/fixeol.py b/devtools/fixeol.py
index 8b97e90..53af761 100644
--- a/devtools/fixeol.py
+++ b/devtools/fixeol.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import os.path
def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ):
@@ -7,7 +8,7 @@
try:
f = open(path, 'rb')
except IOError as msg:
- print >> sys.stderr, "%s: I/O Error: %s" % (file, str(msg))
+ print("%s: I/O Error: %s" % (file, str(msg)), file=sys.stderr)
return False
try:
raw_lines = f.readlines()
@@ -15,7 +16,7 @@
f.close()
fixed_lines = [line.rstrip('\r\n') + eol for line in raw_lines]
if raw_lines != fixed_lines:
- print '%s =>' % path,
+ print('%s =>' % path, end=' ')
if not is_dry_run:
f = open(path, "wb")
try:
@@ -23,7 +24,7 @@
finally:
f.close()
if verbose:
- print is_dry_run and ' NEED FIX' or ' FIXED'
+ print(is_dry_run and ' NEED FIX' or ' FIXED')
return True
##
##
diff --git a/devtools/licenseupdater.py b/devtools/licenseupdater.py
index 866eada..8cb71d7 100644
--- a/devtools/licenseupdater.py
+++ b/devtools/licenseupdater.py
@@ -1,5 +1,6 @@
"""Updates the license text in source file.
"""
+from __future__ import print_function
# An existing license is found if the file starts with the string below,
# and ends with the first blank line.
@@ -34,11 +35,11 @@
if not dry_run:
with open( path, 'wb' ) as fout:
fout.write( new_text.replace('\n', newline ) )
- print 'Updated', path
+ print('Updated', path)
if show_diff:
import difflib
- print '\n'.join( difflib.unified_diff( original_text.split('\n'),
- new_text.split('\n') ) )
+ print('\n'.join( difflib.unified_diff( original_text.split('\n'),
+ new_text.split('\n') ) ))
return True
return False
@@ -83,7 +84,7 @@
parser.enable_interspersed_args()
options, args = parser.parse_args()
update_license_in_source_directories( args, options.dry_run, options.show_diff )
- print 'Done'
+ print('Done')
if __name__ == '__main__':
import sys