misc.python.materialize.terminal
Terminal utilities.
1# Copyright Materialize, Inc. and contributors. All rights reserved. 2# 3# Use of this software is governed by the Business Source License 4# included in the LICENSE file at the root of this repository. 5# 6# As of the Change Date specified in that file, in accordance with 7# the Business Source License, use of this software will be governed 8# by the Apache License, Version 2.0. 9 10"""Terminal utilities.""" 11 12COLOR_GREEN = "\033[92m" 13COLOR_RED = "\033[91m" 14COLOR_BLUE = "\033[34m" 15COLOR_CYAN = "\033[36m" 16COLOR_OK = COLOR_GREEN 17COLOR_ERROR = COLOR_RED 18COLOR_GOOD = COLOR_GREEN 19COLOR_BAD = COLOR_RED 20STYLE_BOLD = "\033[1m" 21_END_FORMATTING = "\033[0m" 22 23 24def with_formatting(text: str, formatting: str) -> str: 25 return with_formattings(text, [formatting]) 26 27 28def with_conditional_formatting(text: str, formatting: str, condition: bool) -> str: 29 if condition: 30 return with_formatting(text, formatting) 31 32 return text 33 34 35def with_formattings(text: str, formattings: list[str]) -> str: 36 formatting = "".join(formattings) 37 return f"{formatting}{text}{_END_FORMATTING}"
COLOR_GREEN =
'\x1b[92m'
COLOR_RED =
'\x1b[91m'
COLOR_BLUE =
'\x1b[34m'
COLOR_CYAN =
'\x1b[36m'
COLOR_OK =
'\x1b[92m'
COLOR_ERROR =
'\x1b[91m'
COLOR_GOOD =
'\x1b[92m'
COLOR_BAD =
'\x1b[91m'
STYLE_BOLD =
'\x1b[1m'
def
with_formatting(text: str, formatting: str) -> str:
def
with_conditional_formatting(text: str, formatting: str, condition: bool) -> str:
def
with_formattings(text: str, formattings: list[str]) -> str: