mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
patman: Convert camel case in terminal.py
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
252ac58996
commit
098b10fb34
8 changed files with 82 additions and 82 deletions
|
@ -22,7 +22,7 @@ from buildman import toolchain
|
|||
from patman import command
|
||||
from patman import gitutil
|
||||
from patman import terminal
|
||||
from patman.terminal import Tprint
|
||||
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.
|
||||
|
@ -508,7 +508,7 @@ class Builder:
|
|||
if result.already_done:
|
||||
self.already_done += 1
|
||||
if self._verbose:
|
||||
terminal.PrintClear()
|
||||
terminal.print_clear()
|
||||
boards_selected = {target : result.brd}
|
||||
self.ResetResultSummary(boards_selected)
|
||||
self.ProduceResultSummary(result.commit_upto, self.commits,
|
||||
|
@ -535,8 +535,8 @@ class Builder:
|
|||
line += '%s : ' % self._complete_delay
|
||||
|
||||
line += target
|
||||
terminal.PrintClear()
|
||||
Tprint(line, newline=False, limit_to_line=True)
|
||||
terminal.print_clear()
|
||||
tprint(line, newline=False, limit_to_line=True)
|
||||
|
||||
def _GetOutputDir(self, commit_upto):
|
||||
"""Get the name of the output directory for a commit number
|
||||
|
@ -666,7 +666,7 @@ class Builder:
|
|||
if line.strip():
|
||||
size, type, name = line[:-1].split()
|
||||
except:
|
||||
Tprint("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
|
||||
|
@ -1009,16 +1009,16 @@ class Builder:
|
|||
return
|
||||
args = [self.ColourNum(x) for x in args]
|
||||
indent = ' ' * 15
|
||||
Tprint('%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.build(self.col.YELLOW, fname)] + args))
|
||||
Tprint('%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)
|
||||
Tprint(msg, colour=color)
|
||||
tprint(msg, colour=color)
|
||||
|
||||
|
||||
def PrintSizeDetail(self, target_list, show_bloat):
|
||||
|
@ -1043,12 +1043,12 @@ class Builder:
|
|||
color = self.col.RED if diff > 0 else self.col.GREEN
|
||||
msg = ' %s %+d' % (name, diff)
|
||||
if not printed_target:
|
||||
Tprint('%10s %-15s:' % ('', result['_target']),
|
||||
tprint('%10s %-15s:' % ('', result['_target']),
|
||||
newline=False)
|
||||
printed_target = True
|
||||
Tprint(msg, colour=color, newline=False)
|
||||
tprint(msg, colour=color, newline=False)
|
||||
if printed_target:
|
||||
Tprint()
|
||||
tprint()
|
||||
if show_bloat:
|
||||
target = result['_target']
|
||||
outcome = result['_outcome']
|
||||
|
@ -1153,13 +1153,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:
|
||||
Tprint('%10s: (for %d/%d boards)' % (arch, count,
|
||||
tprint('%10s: (for %d/%d boards)' % (arch, count,
|
||||
arch_count[arch]), newline=False)
|
||||
printed_arch = True
|
||||
Tprint(msg, colour=color, newline=False)
|
||||
tprint(msg, colour=color, newline=False)
|
||||
|
||||
if printed_arch:
|
||||
Tprint()
|
||||
tprint()
|
||||
if show_detail:
|
||||
self.PrintSizeDetail(target_list, show_bloat)
|
||||
|
||||
|
@ -1304,7 +1304,7 @@ class Builder:
|
|||
col = self.col.RED
|
||||
elif line[0] == 'c':
|
||||
col = self.col.YELLOW
|
||||
Tprint(' ' + 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
|
||||
|
@ -1331,7 +1331,7 @@ class Builder:
|
|||
else:
|
||||
out = self.col.build(colour, line.char + line.errline)
|
||||
out_list.append(out)
|
||||
Tprint('\n'.join(out_list))
|
||||
tprint('\n'.join(out_list))
|
||||
self._error_lines += 1
|
||||
|
||||
|
||||
|
@ -1385,7 +1385,7 @@ class Builder:
|
|||
self.AddOutcome(board_selected, arch_list, unknown_boards, '?',
|
||||
self.col.MAGENTA)
|
||||
for arch, target_list in arch_list.items():
|
||||
Tprint('%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)
|
||||
|
@ -1515,13 +1515,13 @@ class Builder:
|
|||
_AddConfig(lines, 'all', all_plus, all_minus, all_change)
|
||||
#arch_summary[target] = '\n'.join(lines)
|
||||
if lines:
|
||||
Tprint('%s:' % arch)
|
||||
tprint('%s:' % arch)
|
||||
_OutputConfigInfo(lines)
|
||||
|
||||
for lines, targets in lines_by_target.items():
|
||||
if not lines:
|
||||
continue
|
||||
Tprint('%s :' % ' '.join(sorted(targets)))
|
||||
tprint('%s :' % ' '.join(sorted(targets)))
|
||||
_OutputConfigInfo(lines.split('\n'))
|
||||
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ class Builder:
|
|||
if not board in board_dict:
|
||||
not_built.append(board)
|
||||
if not_built:
|
||||
Tprint("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):
|
||||
|
@ -1553,7 +1553,7 @@ class Builder:
|
|||
if commits:
|
||||
msg = '%02d: %s' % (commit_upto + 1,
|
||||
commits[commit_upto].subject)
|
||||
Tprint(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,
|
||||
|
@ -1578,7 +1578,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:
|
||||
Tprint('(no errors to report)', colour=self.col.GREEN)
|
||||
tprint('(no errors to report)', colour=self.col.GREEN)
|
||||
|
||||
|
||||
def SetupBuild(self, board_selected, commits):
|
||||
|
@ -1629,10 +1629,10 @@ 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.
|
||||
Tprint('\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()
|
||||
terminal.print_clear()
|
||||
elif os.path.isfile(git_dir):
|
||||
# This is a worktree of the src_dir repo, we don't need to
|
||||
# create it again or update it in any way.
|
||||
|
@ -1643,15 +1643,15 @@ class Builder:
|
|||
raise ValueError('Git dir %s exists, but is not a file '
|
||||
'or a directory.' % git_dir)
|
||||
elif setup_git == 'worktree':
|
||||
Tprint('\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()
|
||||
terminal.print_clear()
|
||||
elif setup_git == 'clone' or setup_git == True:
|
||||
Tprint('\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()
|
||||
terminal.print_clear()
|
||||
else:
|
||||
raise ValueError("Can't setup git repo with %s." % setup_git)
|
||||
|
||||
|
@ -1717,11 +1717,11 @@ class Builder:
|
|||
"""
|
||||
to_remove = self._GetOutputSpaceRemovals()
|
||||
if to_remove:
|
||||
Tprint('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)
|
||||
terminal.PrintClear()
|
||||
terminal.print_clear()
|
||||
|
||||
def BuildBoards(self, commits, board_selected, keep_outputs, verbose):
|
||||
"""Build all commits for a list of boards
|
||||
|
@ -1747,7 +1747,7 @@ class Builder:
|
|||
self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)),
|
||||
commits is not None)
|
||||
self._PrepareOutputSpace()
|
||||
Tprint('\rStarting build...', newline=False)
|
||||
tprint('\rStarting build...', newline=False)
|
||||
self.SetupBuild(board_selected, commits)
|
||||
self.ProcessResult(None)
|
||||
self.thread_exceptions = []
|
||||
|
@ -1774,7 +1774,7 @@ class Builder:
|
|||
|
||||
# Wait until we have processed all output
|
||||
self.out_queue.join()
|
||||
Tprint()
|
||||
tprint()
|
||||
|
||||
msg = 'Completed: %d total built' % self.count
|
||||
if self.already_done:
|
||||
|
@ -1789,9 +1789,9 @@ class Builder:
|
|||
duration = duration - timedelta(microseconds=duration.microseconds)
|
||||
rate = float(self.count) / duration.total_seconds()
|
||||
msg += ', duration %s, rate %1.2f' % (duration, rate)
|
||||
Tprint(msg)
|
||||
tprint(msg)
|
||||
if self.thread_exceptions:
|
||||
Tprint('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)
|
||||
|
|
|
@ -18,7 +18,7 @@ from patman import gitutil
|
|||
from patman import patchstream
|
||||
from patman import terminal
|
||||
from patman import tools
|
||||
from patman.terminal import Tprint
|
||||
from patman.terminal import tprint
|
||||
|
||||
def GetPlural(count):
|
||||
"""Returns a plural 's' if count is not 1"""
|
||||
|
@ -362,7 +362,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
|
|||
else:
|
||||
commits = None
|
||||
|
||||
Tprint(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
|
||||
|
|
|
@ -205,8 +205,8 @@ class TestFunctional(unittest.TestCase):
|
|||
self._test_branch = TEST_BRANCH
|
||||
|
||||
# Avoid sending any output and clear all terminal output
|
||||
terminal.SetPrintTestMode()
|
||||
terminal.GetPrintTestLines()
|
||||
terminal.set_print_test_mode()
|
||||
terminal.get_print_test_lines()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self._base_dir)
|
||||
|
@ -438,7 +438,7 @@ class TestFunctional(unittest.TestCase):
|
|||
print(len(lines))
|
||||
for line in lines:
|
||||
print(line)
|
||||
#self.print_lines(terminal.GetPrintTestLines())
|
||||
#self.print_lines(terminal.get_print_test_lines())
|
||||
|
||||
def testNoBoards(self):
|
||||
"""Test that buildman aborts when there are no boards"""
|
||||
|
@ -450,7 +450,7 @@ class TestFunctional(unittest.TestCase):
|
|||
"""Very simple test to invoke buildman on the current source"""
|
||||
self.setupToolchains();
|
||||
self._RunControl('-o', self._output_dir)
|
||||
lines = terminal.GetPrintTestLines()
|
||||
lines = terminal.get_print_test_lines()
|
||||
self.assertIn('Building current source for %d boards' % len(boards),
|
||||
lines[0].text)
|
||||
|
||||
|
@ -463,7 +463,7 @@ class TestFunctional(unittest.TestCase):
|
|||
"""Test that missing toolchains are detected"""
|
||||
self.setupToolchains();
|
||||
ret_code = self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir)
|
||||
lines = terminal.GetPrintTestLines()
|
||||
lines = terminal.get_print_test_lines()
|
||||
|
||||
# Buildman always builds the upstream commit as well
|
||||
self.assertIn('Building %d commits for %d boards' %
|
||||
|
|
|
@ -148,7 +148,7 @@ class TestBuild(unittest.TestCase):
|
|||
self.toolchains.Add('gcc', test=False)
|
||||
|
||||
# Avoid sending any output
|
||||
terminal.SetPrintTestMode()
|
||||
terminal.set_print_test_mode()
|
||||
self._col = terminal.Color()
|
||||
|
||||
self.base_dir = tempfile.mkdtemp()
|
||||
|
@ -209,7 +209,7 @@ class TestBuild(unittest.TestCase):
|
|||
# associated with each. This calls our Make() to inject the fake output.
|
||||
build.BuildBoards(self.commits, board_selected, keep_outputs=False,
|
||||
verbose=False)
|
||||
lines = terminal.GetPrintTestLines()
|
||||
lines = terminal.get_print_test_lines()
|
||||
count = 0
|
||||
for line in lines:
|
||||
if line.text.strip():
|
||||
|
@ -221,8 +221,8 @@ class TestBuild(unittest.TestCase):
|
|||
build.SetDisplayOptions(**kwdisplay_args);
|
||||
build.ShowSummary(self.commits, board_selected)
|
||||
if echo_lines:
|
||||
terminal.EchoPrintTestLines()
|
||||
return iter(terminal.GetPrintTestLines())
|
||||
terminal.echo_print_test_lines()
|
||||
return iter(terminal.get_print_test_lines())
|
||||
|
||||
def _CheckOutput(self, lines, list_error_boards=False,
|
||||
filter_dtb_warnings=False,
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue