aboutsummaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-29 14:14:17 -0700
committerSimon Glass <sjg@chromium.org>2022-02-09 12:30:13 -0700
commit252ac589969acbc4c17379a4e862a18e1518d12d (patch)
treec17e36e0f9590e6de59f812066e6649c22be0000 /tools/patman
parent82e0e732ee2cf6d0e125aeb7ed7de69711f35ec8 (diff)
downloadu-boot-252ac589969acbc4c17379a4e862a18e1518d12d.zip
u-boot-252ac589969acbc4c17379a4e862a18e1518d12d.tar.gz
u-boot-252ac589969acbc4c17379a4e862a18e1518d12d.tar.bz2
patman: Rename Color() method to build()
This method has the same name as its class which is confusing. It is also annoying when searching the code. It builds a string with a colour, so rename it to build(). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/checkpatch.py10
-rw-r--r--tools/patman/control.py6
-rw-r--r--tools/patman/gitutil.py6
-rw-r--r--tools/patman/series.py12
-rw-r--r--tools/patman/terminal.py14
-rw-r--r--tools/patman/tout.py4
6 files changed, 26 insertions, 26 deletions
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 0434190..dd792ef 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -228,11 +228,11 @@ def get_warning_msg(col, msg_type, fname, line, msg):
msg: Message to report
'''
if msg_type == 'warning':
- msg_type = col.Color(col.YELLOW, msg_type)
+ msg_type = col.build(col.YELLOW, msg_type)
elif msg_type == 'error':
- msg_type = col.Color(col.RED, msg_type)
+ msg_type = col.build(col.RED, msg_type)
elif msg_type == 'check':
- msg_type = col.Color(col.MAGENTA, msg_type)
+ msg_type = col.build(col.MAGENTA, msg_type)
line_str = '' if line is None else '%d' % line
return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg)
@@ -248,7 +248,7 @@ def check_patches(verbose, args):
warning_count += result.warnings
check_count += result.checks
print('%d errors, %d warnings, %d checks for %s:' % (result.errors,
- result.warnings, result.checks, col.Color(col.BLUE, fname)))
+ result.warnings, result.checks, col.build(col.BLUE, fname)))
if (len(result.problems) != result.errors + result.warnings +
result.checks):
print("Internal error: some problems lost")
@@ -266,6 +266,6 @@ def check_patches(verbose, args):
color = col.YELLOW
if error_count:
color = col.RED
- print(col.Color(color, str % (error_count, warning_count, check_count)))
+ print(col.build(color, str % (error_count, warning_count, check_count)))
return False
return True
diff --git a/tools/patman/control.py b/tools/patman/control.py
index cea4f3e..b403823 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -50,7 +50,7 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff):
if not count:
str = 'No commits found to process - please use -c flag, or run:\n' \
' git branch --set-upstream-to remote/branch'
- sys.exit(col.Color(col.RED, str))
+ sys.exit(col.build(col.RED, str))
# Read the metadata from the commits
to_do = count - end
@@ -143,13 +143,13 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
cc_file, in_reply_to=in_reply_to, thread=thread,
smtp_server=smtp_server)
else:
- print(col.Color(col.RED, "Not sending emails due to errors/warnings"))
+ print(col.build(col.RED, "Not sending emails due to errors/warnings"))
# For a dry run, just show our actions as a sanity check
if dry_run:
series.ShowActions(patch_files, cmd, process_tags)
if not its_a_go:
- print(col.Color(col.RED, "Email would not be sent"))
+ print(col.build(col.RED, "Email would not be sent"))
os.remove(cc_file)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 8697297..ceaf2ce 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -404,7 +404,7 @@ def check_suppress_cc_config():
if suppresscc == 'all' or suppresscc == 'cccmd':
col = terminal.Color()
- print((col.Color(col.RED, "error") +
+ print((col.build(col.RED, "error") +
": git config sendemail.suppresscc set to %s\n" % (suppresscc)) +
" patman needs --cc-cmd to be run to set the cc list.\n" +
" Please run:\n" +
@@ -577,14 +577,14 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0):
if warn_on_error:
raise OSError(msg)
else:
- print(col.Color(col.RED, msg))
+ print(col.build(col.RED, msg))
return out_list
if lookup_name:
if not lookup_name in alias:
msg = "Alias '%s' not found" % lookup_name
if warn_on_error:
- print(col.Color(col.RED, msg))
+ print(col.build(col.RED, msg))
return out_list
for item in alias[lookup_name]:
todo = lookup_email(item, alias, warn_on_error, level + 1)
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 27dd3e1..891f278 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -118,11 +118,11 @@ class Series(dict):
# 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.build(col.GREEN, ' %s' % args[upto]))
cc_list = list(self._generated_cc[commit.patch])
for email in sorted(set(cc_list) - to_set - cc_set):
if email == None:
- email = col.Color(col.YELLOW, "<alias '%s' not found>"
+ email = col.build(col.YELLOW, "<alias '%s' not found>"
% tag)
if email:
print(' Cc: ', email)
@@ -227,13 +227,13 @@ class Series(dict):
else:
if version > 1:
str = 'Change log missing for v%d' % version
- print(col.Color(col.RED, str))
+ print(col.build(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.build(col.RED, str))
elif self.changes:
str = 'Change log exists, but no version is set'
- print(col.Color(col.RED, str))
+ print(col.build(col.RED, str))
def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
add_maintainers, limit):
@@ -271,7 +271,7 @@ class Series(dict):
dir_list = [os.path.join(gitutil.get_top_level(), 'scripts')]
cc += get_maintainer.get_maintainer(dir_list, commit.patch)
for x in set(cc) & set(settings.bounces):
- print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
+ print(col.build(col.YELLOW, 'Skipping "%s"' % x))
cc = list(set(cc) - set(settings.bounces))
if limit is not None:
cc = cc[:limit]
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py
index f76d2b1..e72c55b 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -64,7 +64,7 @@ def CalcAsciiLen(text):
Length of text, after skipping ANSI sequences
>>> col = Color(COLOR_ALWAYS)
- >>> text = col.Color(Color.RED, 'abc')
+ >>> text = col.build(Color.RED, 'abc')
>>> len(text)
14
>>> CalcAsciiLen(text)
@@ -73,7 +73,7 @@ def CalcAsciiLen(text):
>>> text += 'def'
>>> CalcAsciiLen(text)
6
- >>> text += col.Color(Color.RED, 'abc')
+ >>> text += col.build(Color.RED, 'abc')
>>> CalcAsciiLen(text)
9
"""
@@ -87,7 +87,7 @@ def TrimAsciiLen(text, size):
calculation.
>>> col = Color(COLOR_ALWAYS)
- >>> text = col.Color(Color.RED, 'abc')
+ >>> text = col.build(Color.RED, 'abc')
>>> len(text)
14
>>> CalcAsciiLen(TrimAsciiLen(text, 4))
@@ -97,7 +97,7 @@ def TrimAsciiLen(text, size):
>>> text += 'def'
>>> CalcAsciiLen(TrimAsciiLen(text, 4))
4
- >>> text += col.Color(Color.RED, 'ghi')
+ >>> text += col.build(Color.RED, 'ghi')
>>> CalcAsciiLen(TrimAsciiLen(text, 7))
7
"""
@@ -148,7 +148,7 @@ def Tprint(text='', newline=True, colour=None, limit_to_line=False, bright=True)
else:
if colour:
col = Color()
- text = col.Color(colour, text, bright=bright)
+ text = col.build(colour, text, bright=bright)
if newline:
print(text)
last_print_len = None
@@ -191,7 +191,7 @@ def EchoPrintTestLines():
for line in print_test_list:
if line.colour:
col = Color()
- print(col.Color(line.colour, line.text), end='')
+ print(col.build(line.colour, line.text), end='')
else:
print(line.text, end='')
if line.newline:
@@ -247,7 +247,7 @@ class Color(object):
return self.RESET
return ''
- def Color(self, color, text, bright=True):
+ def build(self, color, text, bright=True):
"""Returns text with conditionally added color escape sequences.
Keyword arguments:
diff --git a/tools/patman/tout.py b/tools/patman/tout.py
index 7eb555a..ff0fd92 100644
--- a/tools/patman/tout.py
+++ b/tools/patman/tout.py
@@ -64,7 +64,7 @@ def progress(msg, warning=False, trailer='...'):
_progress = msg + trailer
if stdout_is_tty:
col = _color.YELLOW if warning else _color.GREEN
- _stdout.write('\r' + _color.Color(col, _progress))
+ _stdout.write('\r' + _color.build(col, _progress))
_stdout.flush()
in_progress = True
else:
@@ -82,7 +82,7 @@ def _output(level, msg, color=None):
if verbose >= level:
clear_progress()
if color:
- msg = _color.Color(color, msg)
+ msg = _color.build(color, msg)
if level < NOTICE:
print(msg, file=sys.stderr)
else: