Skip to content

Commit 442f45b

Browse files
committed
pump.py: add support for Python 3
1 parent e8a82dc commit 442f45b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

googlemock/scripts/pump.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2.7
1+
#!/usr/bin/env python
22
#
33
# Copyright 2008, Google Inc.
44
# All rights reserved.
@@ -64,6 +64,7 @@
6464

6565
from __future__ import print_function
6666

67+
import io
6768
import os
6869
import re
6970
import sys
@@ -834,19 +835,19 @@ def main(argv):
834835
sys.exit(1)
835836

836837
file_path = argv[-1]
837-
output_str = ConvertFromPumpSource(file(file_path, 'r').read())
838+
output_str = ConvertFromPumpSource(io.open(file_path, 'r').read())
838839
if file_path.endswith('.pump'):
839840
output_file_path = file_path[:-5]
840841
else:
841842
output_file_path = '-'
842843
if output_file_path == '-':
843844
print(output_str,)
844845
else:
845-
output_file = file(output_file_path, 'w')
846-
output_file.write('// This file was GENERATED by command:\n')
847-
output_file.write('// %s %s\n' %
846+
output_file = io.open(output_file_path, 'w')
847+
output_file.write(u'// This file was GENERATED by command:\n')
848+
output_file.write(u'// %s %s\n' %
848849
(os.path.basename(__file__), os.path.basename(file_path)))
849-
output_file.write('// DO NOT EDIT BY HAND!!!\n\n')
850+
output_file.write(u'// DO NOT EDIT BY HAND!!!\n\n')
850851
output_file.write(output_str)
851852
output_file.close()
852853

0 commit comments

Comments
 (0)