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:
Chang Bo Guo 2013-09-18 02:35:53 -07:00
parent 0712325922
commit 264f1f612e
2 changed files with 25 additions and 25 deletions

View File

@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import compiler
import imp
@ -56,15 +57,14 @@ class Visitor(object):
if is_localized(node):
for (checker, msg) in self.msg_format_checkers:
if checker(node):
print >> sys.stderr, (
'%s:%d %s: %s' %
print('%s:%d %s: %s Error: %s' %
(self.filename, node.lineno,
self.lines[node.lineno - 1][:-1],
"Error: %s" % msg))
self.lines[node.lineno - 1][:-1], msg),
file=sys.stderr)
self.error = 1
return
if debug:
print ('%s:%d %s: %s' %
print('%s:%d %s: %s' %
(self.filename, node.lineno,
self.lines[node.lineno - 1][:-1],
"Pass"))
@ -73,26 +73,25 @@ class Visitor(object):
if predicate(node):
if action == 'skip':
if debug:
print ('%s:%d %s: %s' %
print('%s:%d %s: %s' %
(self.filename, node.lineno,
self.lines[node.lineno - 1][:-1],
"Pass"))
return
elif action == 'error':
print >> sys.stderr, (
'%s:%d %s: %s' %
print('%s:%d %s: %s Error: %s' %
(self.filename, node.lineno,
self.lines[node.lineno - 1][:-1],
"Error: %s" % msg))
self.lines[node.lineno - 1][:-1], msg),
file=sys.stderr)
self.error = 1
return
elif action == 'warn':
print ('%s:%d %s: %s' %
print('%s:%d %s: %s' %
(self.filename, node.lineno,
self.lines[node.lineno - 1][:-1],
"Warn: %s" % msg))
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):
@ -120,7 +119,7 @@ if __name__ == '__main__':
try:
cfg_mod = imp.load_source('', cfg_path)
except Exception:
print >> sys.stderr, "Load cfg module failed"
print("Load cfg module failed", file=sys.stderr)
sys.exit(1)
i18n_msg_predicates = cfg_mod.i18n_msg_predicates

View File

@ -23,6 +23,7 @@
"""
Installation script for Neutron's development virtualenv
"""
from __future__ import print_function
import os
import subprocess
@ -50,7 +51,7 @@ def print_help():
Also, make test will automatically use the virtualenv.
"""
print help
print(help)
def main(argv):