Merge "Use built-in print() instead of print statement"

This commit is contained in:
Jenkins 2013-09-23 08:32:50 +00:00 committed by Gerrit Code Review
commit b79a6ebcb4
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 # 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,43 +57,41 @@ 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], msg),
self.lines[node.lineno - 1][:-1], file=sys.stderr)
"Error: %s" % msg))
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"))
else: else:
for (predicate, action, msg) in self.i18n_msg_predicates: for (predicate, action, msg) in self.i18n_msg_predicates:
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], msg),
self.lines[node.lineno - 1][:-1], file=sys.stderr)
"Error: %s" % msg))
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

View File

@ -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):