From a920a17b2f418535870788ae81234dc6b8aa6661 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Tue, 27 Sep 2016 16:03:50 +0100 Subject: patman: Make print statements python 3.x safe In python 3.x, print must be used as a function call. Convert all print statements to the function call style, importing from __future__ where we print with no trailing newline or print to a file object. Signed-off-by: Paul Burton Acked-by: Simon Glass --- tools/patman/series.py | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'tools/patman/series.py') diff --git a/tools/patman/series.py b/tools/patman/series.py index 1ce30c673f..38a452edad 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -3,6 +3,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +from __future__ import print_function + import itertools import os @@ -101,38 +103,38 @@ class Series(dict): cc_set = set(gitutil.BuildEmailList(self.cc)); col = terminal.Color() - print 'Dry run, so not doing much. But I would do this:' - print - print 'Send a total of %d patch%s with %scover letter.' % ( + print('Dry run, so not doing much. But I would do this:') + print() + print('Send a total of %d patch%s with %scover letter.' % ( len(args), '' if len(args) == 1 else 'es', - self.get('cover') and 'a ' or 'no ') + self.get('cover') and 'a ' or 'no ')) # TODO: Colour the patches according to whether they passed checks for upto in range(len(args)): commit = self.commits[upto] - print col.Color(col.GREEN, ' %s' % args[upto]) + print(col.Color(col.GREEN, ' %s' % args[upto])) cc_list = list(self._generated_cc[commit.patch]) for email in set(cc_list) - to_set - cc_set: if email == None: email = col.Color(col.YELLOW, "" % tag) if email: - print ' Cc: ',email + print(' Cc: ', email) print for item in to_set: - print 'To:\t ', item + print('To:\t ', item) for item in cc_set - to_set: - print 'Cc:\t ', item - print 'Version: ', self.get('version') - print 'Prefix:\t ', self.get('prefix') + print('Cc:\t ', item) + print('Version: ', self.get('version')) + print('Prefix:\t ', self.get('prefix')) if self.cover: - print 'Cover: %d lines' % len(self.cover) + print('Cover: %d lines' % len(self.cover)) cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) all_ccs = itertools.chain(cover_cc, *self._generated_cc.values()) for email in set(all_ccs) - to_set - cc_set: - print ' Cc: ',email + print(' Cc: ', email) if cmd: - print 'Git command: %s' % cmd + print('Git command: %s' % cmd) def MakeChangeLog(self, commit): """Create a list of changes for each version. @@ -191,13 +193,13 @@ class Series(dict): else: if version > 1: str = 'Change log missing for v%d' % version - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) for version in changes_copy: str = 'Change log for unknown version v%d' % version - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) elif self.changes: str = 'Change log exists, but no version is set' - print col.Color(col.RED, str) + print(col.Color(col.RED, str)) def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers): @@ -228,12 +230,12 @@ class Series(dict): if add_maintainers: list += get_maintainer.GetMaintainer(commit.patch) all_ccs += list - print >>fd, commit.patch, ', '.join(set(list)) + print(commit.patch, ', '.join(set(list)), file=fd) self._generated_cc[commit.patch] = list if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) - print >>fd, cover_fname, ', '.join(set(cover_cc + all_ccs)) + print(cover_fname, ', '.join(set(cover_cc + all_ccs)), file=fd) fd.close() return fname -- cgit v1.2.3