Skip to content

Output

mongorunway.application.output ¤

ERROR = 'error' module-attribute ¤

HEADING_LEVEL_ONE = 1 module-attribute ¤

HEADING_LEVEL_THREE = 3 module-attribute ¤

HEADING_LEVEL_TWO = 2 module-attribute ¤

HEADING_MAP = {HEADING_LEVEL_ONE: ('=', True), HEADING_LEVEL_TWO: ('-', True), HEADING_LEVEL_THREE: ('-', False)} module-attribute ¤

INFO = 'info' module-attribute ¤

SUCCESS = 'success' module-attribute ¤

TOOL_HEADING_NAME: typing.Final[str] = 'Mongorunway' module-attribute ¤

WARNING = 'warning' module-attribute ¤

__all__: typing.Sequence[str] = ('INFO', 'ERROR', 'SUCCESS', 'WARNING', 'HEADING_MAP', 'HEADING_LEVEL_ONE', 'HEADING_LEVEL_TWO', 'HEADING_LEVEL_THREE', 'TOOL_HEADING_NAME', 'AsciiOutput', 'print', 'print_heading', 'print_error', 'print_success', 'print_info', 'print_warning', 'print_new_line', 'verbose_print') module-attribute ¤

AsciiOutput ¤

Bases: str, enum.Enum

Source code in mongorunway\application\output.py
class AsciiOutput(str, enum.Enum):
    INFO = 128712
    DONE = 10003
    WARNING = 9888
    ERROR = 33

    def __str__(self) -> str:
        return chr(self.value)

DONE = 10003 instance-attribute class-attribute ¤

ERROR = 33 instance-attribute class-attribute ¤

INFO = 128712 instance-attribute class-attribute ¤

WARNING = 9888 instance-attribute class-attribute ¤

__str__() ¤

Source code in mongorunway\application\output.py
def __str__(self) -> str:
    return chr(self.value)

print(text='', bold=False, newline=True, symbol='') ¤

Source code in mongorunway\application\output.py
def print(
    text: str = "",
    bold: bool = False,
    newline: bool = True,
    symbol: str = "",
) -> None:
    if symbol:
        text = symbol + " " + text

    click.secho(text, bold=bold, nl=newline)

print_error(text, bold=False) ¤

Source code in mongorunway\application\output.py
def print_error(text: str, bold: bool = False) -> None:
    print(text, bold=bold, symbol=AsciiOutput.ERROR)

print_heading(level, text, indent=True) ¤

Source code in mongorunway\application\output.py
def print_heading(level: int, text: str, indent: bool = True) -> None:
    line_char, show_line_above = HEADING_MAP[level]
    heading_line = line_char * len(text)

    if show_line_above:
        print(heading_line, bold=True)

    print(text, bold=True)
    print(heading_line, bold=True)

    if indent:
        print_new_line()

print_info(text, bold=False) ¤

Source code in mongorunway\application\output.py
def print_info(text: str, bold: bool = False) -> None:
    print(text, bold=bold, symbol=AsciiOutput.INFO)

print_new_line(count=1) ¤

Source code in mongorunway\application\output.py
def print_new_line(count: int = 1) -> None:
    for i in range(count):
        click.secho()

print_success(text, bold=False) ¤

Source code in mongorunway\application\output.py
def print_success(text: str, bold: bool = False) -> None:
    print(text, bold=bold, symbol=AsciiOutput.DONE)

print_warning(text, bold=False) ¤

Source code in mongorunway\application\output.py
def print_warning(text: str, bold: bool = False) -> None:
    print(text, bold=bold, symbol=AsciiOutput.WARNING)

verbose_print(verbose, text='', bold=False, newline=True, symbol='') ¤

Source code in mongorunway\application\output.py
def verbose_print(
    verbose: bool,
    text: str = "",
    bold: bool = False,
    newline: bool = True,
    symbol: str = "",
) -> None:
    if verbose:
        print(
            text=text,
            bold=bold,
            symbol=symbol,
            newline=newline,
        )