Use built-in print() instead of print statement
In python 3 print statement is not supported, so we should use only print() functions. This patch also removes print in unit test, left by accident Fixes bug 1226943 Change-Id: I5ace50cb9e149682344b4c986ef9318f8dc50f72
This commit is contained in:
parent
0712325922
commit
264f1f612e
|
@ -13,6 +13,7 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import compiler
|
import compiler
|
||||||
import imp
|
import imp
|
||||||
|
@ -56,15 +57,14 @@ class Visitor(object):
|
||||||
if is_localized(node):
|
if is_localized(node):
|
||||||
for (checker, msg) in self.msg_format_checkers:
|
for (checker, msg) in self.msg_format_checkers:
|
||||||
if checker(node):
|
if checker(node):
|
||||||
print >> sys.stderr, (
|
print('%s:%d %s: %s Error: %s' %
|
||||||
'%s:%d %s: %s' %
|
|
||||||
(self.filename, node.lineno,
|
(self.filename, node.lineno,
|
||||||
self.lines[node.lineno - 1][:-1],
|
self.lines[node.lineno - 1][:-1], msg),
|
||||||
"Error: %s" % msg))
|
file=sys.stderr)
|
||||||
self.error = 1
|
self.error = 1
|
||||||
return
|
return
|
||||||
if debug:
|
if debug:
|
||||||
print ('%s:%d %s: %s' %
|
print('%s:%d %s: %s' %
|
||||||
(self.filename, node.lineno,
|
(self.filename, node.lineno,
|
||||||
self.lines[node.lineno - 1][:-1],
|
self.lines[node.lineno - 1][:-1],
|
||||||
"Pass"))
|
"Pass"))
|
||||||
|
@ -73,26 +73,25 @@ class Visitor(object):
|
||||||
if predicate(node):
|
if predicate(node):
|
||||||
if action == 'skip':
|
if action == 'skip':
|
||||||
if debug:
|
if debug:
|
||||||
print ('%s:%d %s: %s' %
|
print('%s:%d %s: %s' %
|
||||||
(self.filename, node.lineno,
|
(self.filename, node.lineno,
|
||||||
self.lines[node.lineno - 1][:-1],
|
self.lines[node.lineno - 1][:-1],
|
||||||
"Pass"))
|
"Pass"))
|
||||||
return
|
return
|
||||||
elif action == 'error':
|
elif action == 'error':
|
||||||
print >> sys.stderr, (
|
print('%s:%d %s: %s Error: %s' %
|
||||||
'%s:%d %s: %s' %
|
|
||||||
(self.filename, node.lineno,
|
(self.filename, node.lineno,
|
||||||
self.lines[node.lineno - 1][:-1],
|
self.lines[node.lineno - 1][:-1], msg),
|
||||||
"Error: %s" % msg))
|
file=sys.stderr)
|
||||||
self.error = 1
|
self.error = 1
|
||||||
return
|
return
|
||||||
elif action == 'warn':
|
elif action == 'warn':
|
||||||
print ('%s:%d %s: %s' %
|
print('%s:%d %s: %s' %
|
||||||
(self.filename, node.lineno,
|
(self.filename, node.lineno,
|
||||||
self.lines[node.lineno - 1][:-1],
|
self.lines[node.lineno - 1][:-1],
|
||||||
"Warn: %s" % msg))
|
"Warn: %s" % msg))
|
||||||
return
|
return
|
||||||
print >> sys.stderr, 'Predicate with wrong action!'
|
print('Predicate with wrong action!', file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def is_file_in_black_list(black_list, f):
|
def is_file_in_black_list(black_list, f):
|
||||||
|
@ -120,7 +119,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
cfg_mod = imp.load_source('', cfg_path)
|
cfg_mod = imp.load_source('', cfg_path)
|
||||||
except Exception:
|
except Exception:
|
||||||
print >> sys.stderr, "Load cfg module failed"
|
print("Load cfg module failed", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
i18n_msg_predicates = cfg_mod.i18n_msg_predicates
|
i18n_msg_predicates = cfg_mod.i18n_msg_predicates
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"""
|
"""
|
||||||
Installation script for Neutron's development virtualenv
|
Installation script for Neutron's development virtualenv
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -50,7 +51,7 @@ def print_help():
|
||||||
|
|
||||||
Also, make test will automatically use the virtualenv.
|
Also, make test will automatically use the virtualenv.
|
||||||
"""
|
"""
|
||||||
print help
|
print(help)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
Loading…
Reference in New Issue