aboutsummaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/func_test.py14
-rwxr-xr-xtools/patman/main.py2
-rw-r--r--tools/patman/status.py16
-rw-r--r--tools/patman/terminal.py42
4 files changed, 37 insertions, 37 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 9e869c58ff..59ee90c344 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -45,7 +45,7 @@ class TestFunctional(unittest.TestCase):
def tearDown(self):
shutil.rmtree(self.tmpdir)
- terminal.SetPrintTestMode(False)
+ terminal.set_print_test_mode(False)
@staticmethod
def _get_path(fname):
@@ -907,10 +907,10 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
series = Series()
series.commits = [commit1, commit2]
- terminal.SetPrintTestMode()
+ terminal.set_print_test_mode()
status.check_patchwork_status(series, '1234', None, None, False, False,
None, self._fake_patchwork2)
- lines = iter(terminal.GetPrintTestLines())
+ lines = iter(terminal.get_print_test_lines())
col = terminal.Color()
self.assertEqual(terminal.PrintLine(' 1 Subject 1', col.BLUE),
next(lines))
@@ -1021,11 +1021,11 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
# 4 responses added from patchwork into new branch 'first2'
# <unittest.result.TestResult run=8 errors=0 failures=0>
- terminal.SetPrintTestMode()
+ terminal.set_print_test_mode()
status.check_patchwork_status(series, '1234', branch, dest_branch,
False, False, None, self._fake_patchwork3,
repo)
- lines = terminal.GetPrintTestLines()
+ lines = terminal.get_print_test_lines()
self.assertEqual(12, len(lines))
self.assertEqual(
"4 responses added from patchwork into new branch 'first2'",
@@ -1223,10 +1223,10 @@ Reviewed-by: %s
series = Series()
series.commits = [commit1, commit2]
- terminal.SetPrintTestMode()
+ terminal.set_print_test_mode()
status.check_patchwork_status(series, '1234', None, None, False, True,
None, self._fake_patchwork2)
- lines = iter(terminal.GetPrintTestLines())
+ lines = iter(terminal.get_print_test_lines())
col = terminal.Color()
self.assertEqual(terminal.PrintLine(' 1 Subject 1', col.BLUE),
next(lines))
diff --git a/tools/patman/main.py b/tools/patman/main.py
index d32eae4bfc..2a2ac45709 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -177,7 +177,7 @@ elif args.cmd == 'status':
args.dest_branch, args.force,
args.show_comments, args.patchwork_url)
except Exception as e:
- terminal.Tprint('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 fbed055d34..47ed6d61d4 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.Tprint(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.Tprint(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.Tprint('%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.Tprint('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.Tprint(' %s' % line,
+ terminal.tprint(' %s' % line,
colour=col.MAGENTA if quoted else None)
- terminal.Tprint()
+ terminal.tprint()
- terminal.Tprint("%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.Tprint(
+ 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 e72c55ba98..40d79f8ac0 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -51,7 +51,7 @@ class PrintLine:
(self.newline, self.colour, self.bright, self.text))
-def CalcAsciiLen(text):
+def calc_ascii_len(text):
"""Calculate the length of a string, ignoring any ANSI sequences
When displayed on a terminal, ANSI sequences don't take any space, so we
@@ -67,20 +67,20 @@ def CalcAsciiLen(text):
>>> text = col.build(Color.RED, 'abc')
>>> len(text)
14
- >>> CalcAsciiLen(text)
+ >>> calc_ascii_len(text)
3
>>>
>>> text += 'def'
- >>> CalcAsciiLen(text)
+ >>> calc_ascii_len(text)
6
>>> text += col.build(Color.RED, 'abc')
- >>> CalcAsciiLen(text)
+ >>> calc_ascii_len(text)
9
"""
result = ansi_escape.sub('', text)
return len(result)
-def TrimAsciiLen(text, size):
+def trim_ascii_len(text, size):
"""Trim a string containing ANSI sequences to the given ASCII length
The string is trimmed with ANSI sequences being ignored for the length
@@ -90,18 +90,18 @@ def TrimAsciiLen(text, size):
>>> text = col.build(Color.RED, 'abc')
>>> len(text)
14
- >>> CalcAsciiLen(TrimAsciiLen(text, 4))
+ >>> calc_ascii_len(trim_ascii_len(text, 4))
3
- >>> CalcAsciiLen(TrimAsciiLen(text, 2))
+ >>> calc_ascii_len(trim_ascii_len(text, 2))
2
>>> text += 'def'
- >>> CalcAsciiLen(TrimAsciiLen(text, 4))
+ >>> calc_ascii_len(trim_ascii_len(text, 4))
4
>>> text += col.build(Color.RED, 'ghi')
- >>> CalcAsciiLen(TrimAsciiLen(text, 7))
+ >>> calc_ascii_len(trim_ascii_len(text, 7))
7
"""
- if CalcAsciiLen(text) < size:
+ if calc_ascii_len(text) < size:
return text
pos = 0
out = ''
@@ -130,7 +130,7 @@ def TrimAsciiLen(text, size):
return out
-def Tprint(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
@@ -155,11 +155,11 @@ def Tprint(text='', newline=True, colour=None, limit_to_line=False, bright=True)
else:
if limit_to_line:
cols = shutil.get_terminal_size().columns
- text = TrimAsciiLen(text, cols)
+ text = trim_ascii_len(text, cols)
print(text, end='', flush=True)
- last_print_len = CalcAsciiLen(text)
+ last_print_len = calc_ascii_len(text)
-def PrintClear():
+def print_clear():
"""Clear a previously line that was printed with no newline"""
global last_print_len
@@ -167,15 +167,15 @@ def PrintClear():
print('\r%s\r' % (' '* last_print_len), end='', flush=True)
last_print_len = None
-def SetPrintTestMode(enable=True):
+def set_print_test_mode(enable=True):
"""Go into test mode, where all printing is recorded"""
global print_test_mode
print_test_mode = enable
- GetPrintTestLines()
+ get_print_test_lines()
-def GetPrintTestLines():
- """Get a list of all lines output through Tprint()
+def get_print_test_lines():
+ """Get a list of all lines output through tprint()
Returns:
A list of PrintLine objects
@@ -186,7 +186,7 @@ def GetPrintTestLines():
print_test_list = []
return ret
-def EchoPrintTestLines():
+def echo_print_test_lines():
"""Print out the text lines collected"""
for line in print_test_list:
if line.colour:
@@ -221,7 +221,7 @@ class Color(object):
except:
self._enabled = False
- def Start(self, color, bright=True):
+ def start(self, color, bright=True):
"""Returns a start color code.
Args:
@@ -236,7 +236,7 @@ class Color(object):
return base % (color + 30)
return ''
- def Stop(self):
+ def stop(self):
"""Returns a stop color code.
Returns: