Skip to content

Commit bd1e895

Browse files
committed
simple py3 changes
1 parent 9aa6144 commit bd1e895

File tree

11 files changed

+111
-103
lines changed

11 files changed

+111
-103
lines changed

amalgamate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def amalgamate_source( source_top_dir=None,
5656
target_source_path: output .cpp path
5757
header_include_path: generated header path relative to target_source_path.
5858
"""
59-
print ("Amalgating header...")
59+
print("Amalgating header...")
6060
header = AmalgamationFile( source_top_dir )
6161
header.add_text( "/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/)." )
6262
header.add_text( "/// It is intented to be used with #include <%s>" % header_include_path )
@@ -77,12 +77,12 @@ def amalgamate_source( source_top_dir=None,
7777
header.add_text( "#endif //ifndef JSON_AMALGATED_H_INCLUDED" )
7878

7979
target_header_path = os.path.join( os.path.dirname(target_source_path), header_include_path )
80-
print ("Writing amalgated header to %r" % target_header_path)
80+
print("Writing amalgated header to %r" % target_header_path)
8181
header.write_to( target_header_path )
8282

8383
base, ext = os.path.splitext( header_include_path )
8484
forward_header_include_path = base + "-forwards" + ext
85-
print ("Amalgating forward header...")
85+
print("Amalgating forward header...")
8686
header = AmalgamationFile( source_top_dir )
8787
header.add_text( "/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/)." )
8888
header.add_text( "/// It is intented to be used with #include <%s>" % forward_header_include_path )
@@ -99,10 +99,10 @@ def amalgamate_source( source_top_dir=None,
9999

100100
target_forward_header_path = os.path.join( os.path.dirname(target_source_path),
101101
forward_header_include_path )
102-
print ("Writing amalgated forward header to %r" % target_forward_header_path)
102+
print("Writing amalgated forward header to %r" % target_forward_header_path)
103103
header.write_to( target_forward_header_path )
104104

105-
print ("Amalgating source...")
105+
print("Amalgating source...")
106106
source = AmalgamationFile( source_top_dir )
107107
source.add_text( "/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/)." )
108108
source.add_text( "/// It is intented to be used with #include <%s>" % header_include_path )
@@ -118,7 +118,7 @@ def amalgamate_source( source_top_dir=None,
118118
source.add_file( os.path.join(lib_json, "json_value.cpp") )
119119
source.add_file( os.path.join(lib_json, "json_writer.cpp") )
120120

121-
print ("Writing amalgated source to %r" % target_source_path)
121+
print("Writing amalgated source to %r" % target_source_path)
122122
source.write_to( target_source_path )
123123

124124
def main():
@@ -144,7 +144,7 @@ def main():
144144
sys.stderr.write( msg + "\n" )
145145
sys.exit( 1 )
146146
else:
147-
print ("Source succesfully amalagated")
147+
print("Source succesfully amalagated")
148148

149149
if __name__ == "__main__":
150150
main()

devtools/antglob.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# encoding: utf-8
33
# Baptiste Lepilleur, 2009
44

5+
from __future__ import print_function
56
from dircache import listdir
67
import re
78
import fnmatch
@@ -190,12 +191,12 @@ def local_path( paths ):
190191
test_cases.append( (ant_pattern, local_path(accepted_matches), local_path( rejected_matches )) )
191192
for ant_pattern, accepted_matches, rejected_matches in test_cases:
192193
rex = ant_pattern_to_re( ant_pattern )
193-
print 'ant_pattern:', ant_pattern, ' => ', rex.pattern
194+
print('ant_pattern:', ant_pattern, ' => ', rex.pattern)
194195
for accepted_match in accepted_matches:
195-
print 'Accepted?:', accepted_match
196-
self.assert_( rex.match( accepted_match ) is not None )
196+
print('Accepted?:', accepted_match)
197+
self.assertTrue( rex.match( accepted_match ) is not None )
197198
for rejected_match in rejected_matches:
198-
print 'Rejected?:', rejected_match
199-
self.assert_( rex.match( rejected_match ) is None )
199+
print('Rejected?:', rejected_match)
200+
self.assertTrue( rex.match( rejected_match ) is None )
200201

201202
unittest.main()

devtools/fixeol.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os.path
23

34
def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ):
@@ -7,23 +8,23 @@ def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ):
78
try:
89
f = open(path, 'rb')
910
except IOError as msg:
10-
print >> sys.stderr, "%s: I/O Error: %s" % (file, str(msg))
11+
print("%s: I/O Error: %s" % (file, str(msg)), file=sys.stderr)
1112
return False
1213
try:
1314
raw_lines = f.readlines()
1415
finally:
1516
f.close()
1617
fixed_lines = [line.rstrip('\r\n') + eol for line in raw_lines]
1718
if raw_lines != fixed_lines:
18-
print '%s =>' % path,
19+
print('%s =>' % path, end=' ')
1920
if not is_dry_run:
2021
f = open(path, "wb")
2122
try:
2223
f.writelines(fixed_lines)
2324
finally:
2425
f.close()
2526
if verbose:
26-
print is_dry_run and ' NEED FIX' or ' FIXED'
27+
print(is_dry_run and ' NEED FIX' or ' FIXED')
2728
return True
2829
##
2930
##

devtools/licenseupdater.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Updates the license text in source file.
22
"""
3+
from __future__ import print_function
34

45
# An existing license is found if the file starts with the string below,
56
# and ends with the first blank line.
@@ -34,11 +35,11 @@ def update_license( path, dry_run, show_diff ):
3435
if not dry_run:
3536
with open( path, 'wb' ) as fout:
3637
fout.write( new_text.replace('\n', newline ) )
37-
print 'Updated', path
38+
print('Updated', path)
3839
if show_diff:
3940
import difflib
40-
print '\n'.join( difflib.unified_diff( original_text.split('\n'),
41-
new_text.split('\n') ) )
41+
print('\n'.join( difflib.unified_diff( original_text.split('\n'),
42+
new_text.split('\n') ) ))
4243
return True
4344
return False
4445

@@ -83,7 +84,7 @@ def main():
8384
parser.enable_interspersed_args()
8485
options, args = parser.parse_args()
8586
update_license_in_source_directories( args, options.dry_run, options.show_diff )
86-
print 'Done'
87+
print('Done')
8788

8889
if __name__ == '__main__':
8990
import sys

doxybuild.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Script to generate doxygen documentation.
22
"""
3-
3+
from __future__ import print_function
4+
from devtools import tarball
45
import re
56
import os
67
import os.path
78
import sys
89
import shutil
9-
from devtools import tarball
1010

1111
def find_program(*filenames):
1212
"""find a program in folders path_lst, and sets env[var]
@@ -33,17 +33,17 @@ def do_subst_in_file(targetfile, sourcefile, dict):
3333
contents = f.read()
3434
f.close()
3535
except:
36-
print "Can't read source file %s"%sourcefile
36+
print("Can't read source file %s"%sourcefile)
3737
raise
38-
for (k,v) in dict.items():
38+
for (k,v) in list(dict.items()):
3939
v = v.replace('\\','\\\\')
4040
contents = re.sub(k, v, contents)
4141
try:
4242
f = open(targetfile, 'wb')
4343
f.write(contents)
4444
f.close()
4545
except:
46-
print "Can't write target file %s"%targetfile
46+
print("Can't write target file %s"%targetfile)
4747
raise
4848

4949
def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
@@ -53,12 +53,12 @@ def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
5353
try:
5454
os.chdir( working_dir )
5555
cmd = [doxygen_path, config_file]
56-
print 'Running:', ' '.join( cmd )
56+
print('Running:', ' '.join( cmd ))
5757
try:
5858
import subprocess
5959
except:
6060
if os.system( ' '.join( cmd ) ) != 0:
61-
print 'Documentation generation failed'
61+
print('Documentation generation failed')
6262
return False
6363
else:
6464
if is_silent:
@@ -67,8 +67,8 @@ def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
6767
process = subprocess.Popen( cmd )
6868
stdout, _ = process.communicate()
6969
if process.returncode:
70-
print 'Documentation generation failed:'
71-
print stdout
70+
print('Documentation generation failed:')
71+
print(stdout)
7272
return False
7373
return True
7474
finally:
@@ -107,23 +107,23 @@ def yesno( bool ):
107107
}
108108

109109
if os.path.isdir( output_dir ):
110-
print 'Deleting directory:', output_dir
110+
print('Deleting directory:', output_dir)
111111
shutil.rmtree( output_dir )
112112
if not os.path.isdir( output_dir ):
113113
os.makedirs( output_dir )
114114

115115
do_subst_in_file( 'doc/doxyfile', 'doc/doxyfile.in', subst_keys )
116116
ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent )
117117
if not options.silent:
118-
print open(warning_log_path, 'rb').read()
118+
print(open(warning_log_path, 'rb').read())
119119
index_path = os.path.abspath(os.path.join('doc', subst_keys['%HTML_OUTPUT%'], 'index.html'))
120-
print 'Generated documentation can be found in:'
121-
print index_path
120+
print('Generated documentation can be found in:')
121+
print(index_path)
122122
if options.open:
123123
import webbrowser
124124
webbrowser.open( 'file://' + index_path )
125125
if options.make_tarball:
126-
print 'Generating doc tarball to', tarball_path
126+
print('Generating doc tarball to', tarball_path)
127127
tarball_sources = [
128128
output_dir,
129129
'README.txt',

0 commit comments

Comments
 (0)