mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
IMPALA-11952 (part 2): Fix print function syntax
Python 3 now treats print as a function and requires
the parenthesis in invocation.
print "Hello World!"
is now:
print("Hello World!")
This fixes all locations to use the function
invocation. This is more complicated when the output
is being redirected to a file or when avoiding the
usual newline.
print >> sys.stderr , "Hello World!"
is now:
print("Hello World!", file=sys.stderr)
To support this properly and guarantee equivalent behavior
between python 2 and python 3, all files that use print
now add this import:
from __future__ import print_function
This also fixes random flake8 issues that intersect with
the changes.
Testing:
- check-python-syntax.sh shows no errors related to print
Change-Id: Ib634958369ad777a41e72d80c8053b74384ac351
Reviewed-on: http://gerrit.cloudera.org:8080/19552
Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com>
Reviewed-by: Michael Smith <michael.smith@cloudera.com>
Tested-by: Michael Smith <michael.smith@cloudera.com>
This commit is contained in:
@@ -40,6 +40,7 @@ REPL:
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
from __future__ import print_function
|
||||
import imp
|
||||
import os
|
||||
import re
|
||||
@@ -77,7 +78,7 @@ def dump_config(d, source_path, out):
|
||||
|
||||
-->
|
||||
<configuration>""".format(source_path=os.path.abspath(source_path))
|
||||
print >>out, dedent(header)
|
||||
print(dedent(header), file=out)
|
||||
for k, v in sorted(d.iteritems()):
|
||||
try:
|
||||
k_new = _substitute_env_vars(k)
|
||||
@@ -87,24 +88,24 @@ def dump_config(d, source_path, out):
|
||||
except KeyError as e:
|
||||
raise Exception("failed environment variable substitution for value {k}: {e}"
|
||||
.format(k=k, e=e))
|
||||
print >>out, """\
|
||||
print("""\
|
||||
<property>
|
||||
<name>{name}</name>
|
||||
<value>{value}</value>
|
||||
</property>""".format(name=xmlescape(k_new), value=xmlescape(v_new))
|
||||
print >>out, "</configuration>"
|
||||
</property>""".format(name=xmlescape(k_new), value=xmlescape(v_new)), file=out)
|
||||
print("</configuration>", file=out)
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print >>sys.stderr, "usage: {prog} <template> <out>".format(prog=sys.argv[0])
|
||||
print("usage: {prog} <template> <out>".format(prog=sys.argv[0]), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
_, in_path, out_path = sys.argv
|
||||
try:
|
||||
mod = imp.load_source('template', in_path)
|
||||
except: # noqa
|
||||
print >>sys.stderr, "Unable to load template: %s" % in_path
|
||||
print("Unable to load template: %s" % in_path, file=sys.stderr)
|
||||
raise
|
||||
conf = mod.__dict__.get('CONFIG')
|
||||
if not isinstance(conf, dict):
|
||||
|
||||
Reference in New Issue
Block a user