diff options
author | Tom Rini <trini@konsulko.com> | 2022-02-10 09:02:06 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-02-10 09:19:44 -0500 |
commit | 2ccd2bc8c3580e00c51094c5cc2b3e2ead8d35c3 (patch) | |
tree | 4e7349b8831fee4b342a971025273d3cd042a2f9 /tools/patman/terminal.py | |
parent | 6662e5e406fdee26ba981dd4af3308f51f254f0a (diff) | |
parent | f3078d4ea707931c2307a623ecf6e4d215b413d5 (diff) |
Merge tag 'dm-pull-8feb22-take3' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
patman snake-case conversion
binman fit improvements
ACPI fixes and making MCFG available to ARM
[trini: Update scripts/pylint.base]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'tools/patman/terminal.py')
-rw-r--r-- | tools/patman/terminal.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py index 9be03b3a6fd..40d79f8ac07 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 @@ -64,44 +64,44 @@ 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) + >>> calc_ascii_len(text) 3 >>> >>> text += 'def' - >>> CalcAsciiLen(text) + >>> calc_ascii_len(text) 6 - >>> text += col.Color(Color.RED, 'abc') - >>> CalcAsciiLen(text) + >>> text += col.build(Color.RED, 'abc') + >>> 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 calculation. >>> col = Color(COLOR_ALWAYS) - >>> text = col.Color(Color.RED, 'abc') + >>> 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.Color(Color.RED, 'ghi') - >>> CalcAsciiLen(TrimAsciiLen(text, 7)) + >>> text += col.build(Color.RED, 'ghi') + >>> 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 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 @@ -148,18 +148,18 @@ def Print(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 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 Print() +def get_print_test_lines(): + """Get a list of all lines output through tprint() Returns: A list of PrintLine objects @@ -186,12 +186,12 @@ 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: 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: @@ -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: @@ -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: |