[PATCH 13/17] patman: Rename Print() to Tprint()
Simon Glass
sjg at chromium.org
Sat Jan 29 22:14:16 CET 2022
Rename this function so that when we convert it to snake case it will not
conflict with the built-in print() function.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
tools/buildman/builder.py | 56 +++++++++++++++++++--------------------
tools/buildman/control.py | 4 +--
tools/patman/main.py | 2 +-
tools/patman/status.py | 16 +++++------
tools/patman/terminal.py | 4 +--
5 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 148ab49a136..6687e1c41ca 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -22,7 +22,7 @@ from buildman import toolchain
from patman import command
from patman import gitutil
from patman import terminal
-from patman.terminal import Print
+from patman.terminal import Tprint
# This indicates an new int or hex Kconfig property with no default
# It hangs the build since the 'conf' tool cannot proceed without valid input.
@@ -525,7 +525,7 @@ class Builder:
line += target
terminal.PrintClear()
- Print(line, newline=False, limit_to_line=True)
+ Tprint(line, newline=False, limit_to_line=True)
def _GetOutputDir(self, commit_upto):
"""Get the name of the output directory for a commit number
@@ -655,7 +655,7 @@ class Builder:
if line.strip():
size, type, name = line[:-1].split()
except:
- Print("Invalid line in file '%s': '%s'" % (fname, line[:-1]))
+ Tprint("Invalid line in file '%s': '%s'" % (fname, line[:-1]))
continue
if type in 'tTdDbB':
# function names begin with '.' on 64-bit powerpc
@@ -998,16 +998,16 @@ class Builder:
return
args = [self.ColourNum(x) for x in args]
indent = ' ' * 15
- Print('%s%s: add: %s/%s, grow: %s/%s bytes: %s/%s (%s)' %
+ Tprint('%s%s: add: %s/%s, grow: %s/%s bytes: %s/%s (%s)' %
tuple([indent, self.col.Color(self.col.YELLOW, fname)] + args))
- Print('%s %-38s %7s %7s %+7s' % (indent, 'function', 'old', 'new',
+ Tprint('%s %-38s %7s %7s %+7s' % (indent, 'function', 'old', 'new',
'delta'))
for diff, name in delta:
if diff:
color = self.col.RED if diff > 0 else self.col.GREEN
msg = '%s %-38s %7s %7s %+7d' % (indent, name,
old.get(name, '-'), new.get(name,'-'), diff)
- Print(msg, colour=color)
+ Tprint(msg, colour=color)
def PrintSizeDetail(self, target_list, show_bloat):
@@ -1032,12 +1032,12 @@ class Builder:
color = self.col.RED if diff > 0 else self.col.GREEN
msg = ' %s %+d' % (name, diff)
if not printed_target:
- Print('%10s %-15s:' % ('', result['_target']),
+ Tprint('%10s %-15s:' % ('', result['_target']),
newline=False)
printed_target = True
- Print(msg, colour=color, newline=False)
+ Tprint(msg, colour=color, newline=False)
if printed_target:
- Print()
+ Tprint()
if show_bloat:
target = result['_target']
outcome = result['_outcome']
@@ -1142,13 +1142,13 @@ class Builder:
color = self.col.RED if avg_diff > 0 else self.col.GREEN
msg = ' %s %+1.1f' % (name, avg_diff)
if not printed_arch:
- Print('%10s: (for %d/%d boards)' % (arch, count,
+ Tprint('%10s: (for %d/%d boards)' % (arch, count,
arch_count[arch]), newline=False)
printed_arch = True
- Print(msg, colour=color, newline=False)
+ Tprint(msg, colour=color, newline=False)
if printed_arch:
- Print()
+ Tprint()
if show_detail:
self.PrintSizeDetail(target_list, show_bloat)
@@ -1293,7 +1293,7 @@ class Builder:
col = self.col.RED
elif line[0] == 'c':
col = self.col.YELLOW
- Print(' ' + line, newline=True, colour=col)
+ Tprint(' ' + line, newline=True, colour=col)
def _OutputErrLines(err_lines, colour):
"""Output the line of error/warning lines, if not empty
@@ -1320,7 +1320,7 @@ class Builder:
else:
out = self.col.Color(colour, line.char + line.errline)
out_list.append(out)
- Print('\n'.join(out_list))
+ Tprint('\n'.join(out_list))
self._error_lines += 1
@@ -1374,7 +1374,7 @@ class Builder:
self.AddOutcome(board_selected, arch_list, unknown_boards, '?',
self.col.MAGENTA)
for arch, target_list in arch_list.items():
- Print('%10s: %s' % (arch, target_list))
+ Tprint('%10s: %s' % (arch, target_list))
self._error_lines += 1
_OutputErrLines(better_err, colour=self.col.GREEN)
_OutputErrLines(worse_err, colour=self.col.RED)
@@ -1504,13 +1504,13 @@ class Builder:
_AddConfig(lines, 'all', all_plus, all_minus, all_change)
#arch_summary[target] = '\n'.join(lines)
if lines:
- Print('%s:' % arch)
+ Tprint('%s:' % arch)
_OutputConfigInfo(lines)
for lines, targets in lines_by_target.items():
if not lines:
continue
- Print('%s :' % ' '.join(sorted(targets)))
+ Tprint('%s :' % ' '.join(sorted(targets)))
_OutputConfigInfo(lines.split('\n'))
@@ -1529,7 +1529,7 @@ class Builder:
if not board in board_dict:
not_built.append(board)
if not_built:
- Print("Boards not built (%d): %s" % (len(not_built),
+ Tprint("Boards not built (%d): %s" % (len(not_built),
', '.join(not_built)))
def ProduceResultSummary(self, commit_upto, commits, board_selected):
@@ -1542,7 +1542,7 @@ class Builder:
if commits:
msg = '%02d: %s' % (commit_upto + 1,
commits[commit_upto].subject)
- Print(msg, colour=self.col.BLUE)
+ Tprint(msg, colour=self.col.BLUE)
self.PrintResultSummary(board_selected, board_dict,
err_lines if self._show_errors else [], err_line_boards,
warn_lines if self._show_errors else [], warn_line_boards,
@@ -1567,7 +1567,7 @@ class Builder:
for commit_upto in range(0, self.commit_count, self._step):
self.ProduceResultSummary(commit_upto, commits, board_selected)
if not self._error_lines:
- Print('(no errors to report)', colour=self.col.GREEN)
+ Tprint('(no errors to report)', colour=self.col.GREEN)
def SetupBuild(self, board_selected, commits):
@@ -1618,7 +1618,7 @@ class Builder:
if os.path.isdir(git_dir):
# This is a clone of the src_dir repo, we can keep using
# it but need to fetch from src_dir.
- Print('\rFetching repo for thread %d' % thread_num,
+ Tprint('\rFetching repo for thread %d' % thread_num,
newline=False)
gitutil.fetch(git_dir, thread_dir)
terminal.PrintClear()
@@ -1632,12 +1632,12 @@ class Builder:
raise ValueError('Git dir %s exists, but is not a file '
'or a directory.' % git_dir)
elif setup_git == 'worktree':
- Print('\rChecking out worktree for thread %d' % thread_num,
+ Tprint('\rChecking out worktree for thread %d' % thread_num,
newline=False)
gitutil.add_worktree(src_dir, thread_dir)
terminal.PrintClear()
elif setup_git == 'clone' or setup_git == True:
- Print('\rCloning repo for thread %d' % thread_num,
+ Tprint('\rCloning repo for thread %d' % thread_num,
newline=False)
gitutil.clone(src_dir, thread_dir)
terminal.PrintClear()
@@ -1706,7 +1706,7 @@ class Builder:
"""
to_remove = self._GetOutputSpaceRemovals()
if to_remove:
- Print('Removing %d old build directories...' % len(to_remove),
+ Tprint('Removing %d old build directories...' % len(to_remove),
newline=False)
for dirname in to_remove:
shutil.rmtree(dirname)
@@ -1736,7 +1736,7 @@ class Builder:
self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)),
commits is not None)
self._PrepareOutputSpace()
- Print('\rStarting build...', newline=False)
+ Tprint('\rStarting build...', newline=False)
self.SetupBuild(board_selected, commits)
self.ProcessResult(None)
self.thread_exceptions = []
@@ -1762,7 +1762,7 @@ class Builder:
# Wait until we have processed all output
self.out_queue.join()
- Print()
+ Tprint()
msg = 'Completed: %d total built' % self.count
if self.already_done:
@@ -1777,9 +1777,9 @@ class Builder:
duration = duration - timedelta(microseconds=duration.microseconds)
rate = float(self.count) / duration.total_seconds()
msg += ', duration %s, rate %1.2f' % (duration, rate)
- Print(msg)
+ Tprint(msg)
if self.thread_exceptions:
- Print('Failed: %d thread exceptions' % len(self.thread_exceptions),
+ Tprint('Failed: %d thread exceptions' % len(self.thread_exceptions),
colour=self.col.RED)
return (self.fail, self.warned, self.thread_exceptions)
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 6265178479b..619bd1abd8f 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -17,7 +17,7 @@ from patman import gitutil
from patman import patchstream
from patman import terminal
from patman import tools
-from patman.terminal import Print
+from patman.terminal import Tprint
def GetPlural(count):
"""Returns a plural 's' if count is not 1"""
@@ -358,7 +358,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
else:
commits = None
- Print(GetActionSummary(options.summary, commits, board_selected,
+ Tprint(GetActionSummary(options.summary, commits, board_selected,
options))
# We can't show function sizes without board details at present
diff --git a/tools/patman/main.py b/tools/patman/main.py
index 11cf72835a9..38eaf3d6dc1 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -189,7 +189,7 @@ elif args.cmd == 'status':
args.dest_branch, args.force,
args.show_comments, args.patchwork_url)
except Exception as e:
- terminal.Print('patman: %s: %s' % (type(e).__name__, e),
+ terminal.Tprint('patman: %s: %s' % (type(e).__name__, e),
colour=terminal.Color.RED)
if args.debug:
print()
diff --git a/tools/patman/status.py b/tools/patman/status.py
index ece6b159d20..fbed055d347 100644
--- a/tools/patman/status.py
+++ b/tools/patman/status.py
@@ -338,9 +338,9 @@ def show_responses(rtags, indent, is_new):
for tag in sorted(rtags.keys()):
people = rtags[tag]
for who in sorted(people):
- terminal.Print(indent + '%s %s: ' % ('+' if is_new else ' ', tag),
+ terminal.Tprint(indent + '%s %s: ' % ('+' if is_new else ' ', tag),
newline=False, colour=col.GREEN, bright=is_new)
- terminal.Print(who, colour=col.WHITE, bright=is_new)
+ terminal.Tprint(who, colour=col.WHITE, bright=is_new)
count += 1
return count
@@ -455,7 +455,7 @@ def check_patchwork_status(series, series_id, branch, dest_branch, force,
patch = patch_for_commit.get(seq)
if not patch:
continue
- terminal.Print('%3d %s' % (patch.seq, patch.subject[:50]),
+ terminal.Tprint('%3d %s' % (patch.seq, patch.subject[:50]),
colour=col.BLUE)
cmt = series.commits[seq]
base_rtags = cmt.rtags
@@ -466,15 +466,15 @@ def check_patchwork_status(series, series_id, branch, dest_branch, force,
num_to_add += show_responses(new_rtags, indent, True)
if show_comments:
for review in review_list[seq]:
- terminal.Print('Review: %s' % review.meta, colour=col.RED)
+ terminal.Tprint('Review: %s' % review.meta, colour=col.RED)
for snippet in review.snippets:
for line in snippet:
quoted = line.startswith('>')
- terminal.Print(' %s' % line,
+ terminal.Tprint(' %s' % line,
colour=col.MAGENTA if quoted else None)
- terminal.Print()
+ terminal.Tprint()
- terminal.Print("%d new response%s available in patchwork%s" %
+ terminal.Tprint("%d new response%s available in patchwork%s" %
(num_to_add, 's' if num_to_add != 1 else '',
'' if dest_branch
else ' (use -d to write them to a new branch)'))
@@ -482,6 +482,6 @@ def check_patchwork_status(series, series_id, branch, dest_branch, force,
if dest_branch:
num_added = create_branch(series, new_rtag_list, branch,
dest_branch, force, test_repo)
- terminal.Print(
+ terminal.Tprint(
"%d response%s added from patchwork into new branch '%s'" %
(num_added, 's' if num_added != 1 else '', dest_branch))
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py
index 9be03b3a6fd..f76d2b17772 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -130,7 +130,7 @@ def TrimAsciiLen(text, size):
return out
-def Print(text='', newline=True, colour=None, limit_to_line=False, bright=True):
+def Tprint(text='', newline=True, colour=None, limit_to_line=False, bright=True):
"""Handle a line of output to the terminal.
In test mode this is recorded in a list. Otherwise it is output to the
@@ -175,7 +175,7 @@ def SetPrintTestMode(enable=True):
GetPrintTestLines()
def GetPrintTestLines():
- """Get a list of all lines output through Print()
+ """Get a list of all lines output through Tprint()
Returns:
A list of PrintLine objects
--
2.35.0.rc2.247.g8bbb082509-goog
More information about the U-Boot
mailing list