Skip to content

format#

This package defines formatters for different modes of text output.

Formats

Refer to the Formats documentation to learn about the supported output formats.

DEFAULT_FORMATTER: str #

The default formatter.

FORMATTERS: dict #

The collection of formatters.

new_formatter(mode='ansi', **kwargs) #

Creates a new formatter instance.

Parameters:

Name Type Description Default
mode Option[str]

The mode of the output text. Defaults to DEFAULT_FORMATTER.

'ansi'
**kwargs dict

Appropriate keyword arguments. See BaseFormatter and others.

{}

Returns:

Type Description
Type[picharsso.format.BaseFormatter]

The new formatter instance.

Source code in picharsso/format/__init__.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def new_formatter(mode=DEFAULT_FORMATTER, **kwargs):
    """Creates a new formatter instance.

    Args:
        mode (Option[str]): The mode of the output text.
                            Defaults to `DEFAULT_FORMATTER`.
        **kwargs (dict): Appropriate keyword arguments.
                        See [`BaseFormatter`][picharsso.format.base.BaseFormatter]
                        and others.

    Returns:
        Type[picharsso.format.BaseFormatter] : The new formatter instance.
    """
    return FORMATTERS[mode](**kwargs)