From c724d379b482ab720846932db336b3113ff96d11 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Fri, 16 Oct 2020 21:41:12 +0100 Subject: [PATCH] Updated docs and stubs for terminal_colours --- domdf_python_tools/terminal_colours.py | 2 ++ domdf_python_tools/terminal_colours.pyi | 29 ++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/domdf_python_tools/terminal_colours.py b/domdf_python_tools/terminal_colours.py index fb6bd0b5..36250c42 100644 --- a/domdf_python_tools/terminal_colours.py +++ b/domdf_python_tools/terminal_colours.py @@ -126,6 +126,8 @@ def strip_ansi(value: str) -> str: Strip ANSI colour codes from the given string to return a plaintext output. :param value: + + .. versionadded:: 1.1.0 """ return _ansi_re.sub("", value) diff --git a/domdf_python_tools/terminal_colours.pyi b/domdf_python_tools/terminal_colours.pyi index 9de91df8..783b3dde 100644 --- a/domdf_python_tools/terminal_colours.pyi +++ b/domdf_python_tools/terminal_colours.pyi @@ -28,7 +28,7 @@ See: http://en.wikipedia.org/wiki/ANSI_escape_code # Based on colorama # https://github.com/tartley/colorama # Copyright Jonathan Hartley 2013 -# Distrubuted under the BSD 3-Clause license. +# Distributed under the BSD 3-Clause license. # | Redistribution and use in source and binary forms, with or without # | modification, are permitted provided that the following conditions are met: # | @@ -64,13 +64,13 @@ from typing import List # 3rd party from typing_extensions import Final -CSI: Final[str] = '\033[' -OSC: Final[str] = '\033]' -BEL: Final[str] = '\a' +CSI: Final[str] +OSC: Final[str] +BEL: Final[str] -fore_stack: List[str] = [] -back_stack: List[str] = [] -style_stack: List[str] = [] +fore_stack: List[str] +back_stack: List[str] +style_stack: List[str] def code_to_chars(code) -> str: ... @@ -79,6 +79,9 @@ def clear_screen(mode: int = 2) -> str: ... def clear_line(mode: int = 2) -> str: ... +def strip_ansi(value: str) -> str: ... + + class Colour(str): style: str reset: str @@ -134,8 +137,8 @@ class AnsiFore(AnsiCodes): class AnsiBack(AnsiCodes): - _stack = back_stack - _reset = "\033[49m" + _stack: List[str] + _reset: str BLACK: Colour RED: Colour @@ -160,8 +163,8 @@ class AnsiBack(AnsiCodes): class AnsiStyle(AnsiCodes): - _stack = style_stack - _reset = "\033[22m" + _stack: List[str] + _reset: str BRIGHT: Colour DIM: Colour @@ -173,7 +176,3 @@ Fore = AnsiFore() Back = AnsiBack() Style = AnsiStyle() Cursor = AnsiCursor() - -fore_stack.append(Fore.RESET) -back_stack.append(Back.RESET) -style_stack.append(Style.NORMAL)