summaryrefslogtreecommitdiffstats
path: root/googletest/scripts/pump.py
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/scripts/pump.py')
-rwxr-xr-xgoogletest/scripts/pump.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/googletest/scripts/pump.py b/googletest/scripts/pump.py
index 5efb653..66e3217 100755
--- a/googletest/scripts/pump.py
+++ b/googletest/scripts/pump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
#
# Copyright 2008, Google Inc.
# All rights reserved.
@@ -62,7 +62,7 @@ GRAMMAR:
EXPRESSION has Python syntax.
"""
-__author__ = 'wan@google.com (Zhanyong Wan)'
+from __future__ import print_function
import os
import re
@@ -246,7 +246,7 @@ def ParseToken(lines, pos, regex, token_type):
if m and not m.start():
return MakeToken(lines, pos, pos + m.end(), token_type)
else:
- print 'ERROR: %s expected at %s.' % (token_type, pos)
+ print('ERROR: %s expected at %s.' % (token_type, pos))
sys.exit(1)
@@ -453,8 +453,8 @@ def PushFront(a_list, elem):
def PopToken(a_list, token_type=None):
token = PopFront(a_list)
if token_type is not None and token.token_type != token_type:
- print 'ERROR: %s expected at %s' % (token_type, token.start)
- print 'ERROR: %s found instead' % (token,)
+ print('ERROR: %s expected at %s' % (token_type, token.start))
+ print('ERROR: %s found instead' % (token,))
sys.exit(1)
return token
@@ -616,16 +616,16 @@ class Env:
if identifier == var:
return value
- print 'ERROR: meta variable %s is undefined.' % (identifier,)
+ print('ERROR: meta variable %s is undefined.' % (identifier,))
sys.exit(1)
def EvalExp(self, exp):
try:
result = eval(exp.python_exp)
- except Exception, e:
- print 'ERROR: caught exception %s: %s' % (e.__class__.__name__, e)
- print ('ERROR: failed to evaluate meta expression %s at %s' %
- (exp.python_exp, exp.token.start))
+ except Exception as e: # pylint: disable=broad-except
+ print('ERROR: caught exception %s: %s' % (e.__class__.__name__, e))
+ print('ERROR: failed to evaluate meta expression %s at %s' %
+ (exp.python_exp, exp.token.start))
sys.exit(1)
return result
@@ -634,7 +634,7 @@ class Env:
if identifier == var:
return (lower, upper)
- print 'ERROR: range %s is undefined.' % (identifier,)
+ print('ERROR: range %s is undefined.' % (identifier,))
sys.exit(1)
@@ -694,8 +694,8 @@ def RunAtomicCode(env, node, output):
elif isinstance(node, CodeNode):
RunCode(env.Clone(), node, output)
else:
- print 'BAD'
- print node
+ print('BAD')
+ print(node)
sys.exit(1)
@@ -830,7 +830,7 @@ def ConvertFromPumpSource(src_text):
def main(argv):
if len(argv) == 1:
- print __doc__
+ print(__doc__)
sys.exit(1)
file_path = argv[-1]
@@ -840,7 +840,7 @@ def main(argv):
else:
output_file_path = '-'
if output_file_path == '-':
- print output_str,
+ print(output_str,)
else:
output_file = file(output_file_path, 'w')
output_file.write('// This file was GENERATED by command:\n')