Skip to content

Reference

Frame

hemline.frame.Frame

Source code in hemline/frame.py
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
class Frame:
    def __init__(
        self,
        color: Color | None = None,
        text_alignment: Alignment = DEFAULT_TEXT_ALIGNMENT,
        alignment: Alignment = DEFAULT_FRAME_ALIGNMENT,
        theme: Theme = DEFAULT_THEME,
        horizontal_padding: int = DEFAULT_HORIZONTAL_PADDING,
        vertical_padding: int = DEFAULT_VERTICAL_PADDING,
        outer_width: int = DEFAULT_OUTER_WIDTH,
        container_width: int | None = None,
        colorize: Callable[[str], str] | None = None,
        wrap: Callable[[str, int], str] = DEFAULT_TEXT_WRAP,
    ) -> None:
        """
        Parameters:
            color: The color of the frame. Use this for colorization out
                of the box. For more sophistaced options, you can pass a
                colorization function to the parameter `colorize`.

            text_alignment: The alignment of the text inside the frame.

            alignment: The alignment of the frame inside the container.

            theme: The appearance of the frameline. Choose one the predefined
                themes from hemline.themes or build your own instance of
                hemline.themes.Theme.

            horizontal_padding: The number of whitespace characters used for
                horizontal padding.

            vertical_padding: The number of blank lines used for vertical
                padding.

            outer_width: The outer width of the Frame, including horizontal
                padding and the frame itself.

            container_width: The width of an imgainary container for the frame,
                resorts to the width of the terminal, if none is provided.

            colorize: A function to apply your custom colorization. Must take a
                string return the colorized string. Passing this will override
                any value provided to `color` parameter.

            wrap: A function to apply your custom wrapping logic. Must take a
                string and the width and return the wrapped string.
        """
        self.text_alignment = text_alignment
        self.alignment = alignment
        self.theme = theme
        self.horizontal_padding = horizontal_padding
        self.vertical_padding = vertical_padding
        self.outer_width = outer_width
        self.container_width = container_width
        if not color:
            self.colorize = colorize
        else:
            self.colorize = colorize or partial(default_colorize, color=color)
        self.wrap = wrap

    @property
    def effective_container_width(self) -> int:
        terminal_width = get_terminal_width()
        if self.container_width is None:
            return terminal_width

        return min(self.container_width, terminal_width)

    @property
    def effective_outer_width(self) -> int:
        return min(self.outer_width, self.effective_container_width)

    @property
    def inner_width(self) -> int:
        return self.effective_outer_width - 2

    @property
    def text_width(self) -> int:
        return self.inner_width - 2 * self.horizontal_padding

    @property
    def vertical_border(self) -> str:
        character = self.theme.vertical
        character = self.colorize(character) if self.colorize else character
        return character

    def format(self, text: str) -> str:
        """
        Parameters:
            text: The text to frame.
        """
        text = self.wrap(text, self.text_width)
        raw_lines = text.split("\n")
        raw_lines = (
            [""] * self.vertical_padding
            + raw_lines
            + [""] * self.vertical_padding
        )
        top_line = self._border_line(
            left=self.theme.top_left,
            right=self.theme.top_right,
        )
        bottom_line = self._border_line(
            left=self.theme.bottom_left,
            right=self.theme.bottom_right,
        )
        framed_lines = [self._framed_line(text=line) for line in raw_lines]
        return "\n".join([top_line] + framed_lines + [bottom_line])

    def _pad_line(self, line: str) -> str:
        return (
            " " * self.horizontal_padding + line + " " * self.horizontal_padding
        )

    def _apply_vertical_border(self, line: str) -> str:
        return self.vertical_border + line + self.vertical_border

    def _align_text(self, line: str) -> str:
        return get_alignment_method(self.text_alignment)(line, self.inner_width)

    def _align_framed_line(self, line: str) -> str:
        return get_alignment_method(self.alignment)(
            line, self.effective_container_width
        )

    def _border_line(
        self,
        left: str,
        right: str,
    ) -> str:
        line = left + self.inner_width * self.theme.horizontal + right
        line = self._align_framed_line(line)
        if self.colorize:
            return self.colorize(line)
        return line

    def _framed_line(self, text: str) -> str:
        text = self._pad_line(text)
        text = self._align_text(text)
        text = self._apply_vertical_border(text)
        text = self._align_framed_line(text)
        return text

__init__

__init__(
    color=None,
    text_alignment=DEFAULT_TEXT_ALIGNMENT,
    alignment=DEFAULT_FRAME_ALIGNMENT,
    theme=DEFAULT_THEME,
    horizontal_padding=DEFAULT_HORIZONTAL_PADDING,
    vertical_padding=DEFAULT_VERTICAL_PADDING,
    outer_width=DEFAULT_OUTER_WIDTH,
    container_width=None,
    colorize=None,
    wrap=DEFAULT_TEXT_WRAP,
)

Parameters:

Name Type Description Default
color Color | None

The color of the frame. Use this for colorization out of the box. For more sophistaced options, you can pass a colorization function to the parameter colorize.

None
text_alignment Alignment

The alignment of the text inside the frame.

DEFAULT_TEXT_ALIGNMENT
alignment Alignment

The alignment of the frame inside the container.

DEFAULT_FRAME_ALIGNMENT
theme Theme

The appearance of the frameline. Choose one the predefined themes from hemline.themes or build your own instance of hemline.themes.Theme.

DEFAULT_THEME
horizontal_padding int

The number of whitespace characters used for horizontal padding.

DEFAULT_HORIZONTAL_PADDING
vertical_padding int

The number of blank lines used for vertical padding.

DEFAULT_VERTICAL_PADDING
outer_width int

The outer width of the Frame, including horizontal padding and the frame itself.

DEFAULT_OUTER_WIDTH
container_width int | None

The width of an imgainary container for the frame, resorts to the width of the terminal, if none is provided.

None
colorize Callable[[str], str] | None

A function to apply your custom colorization. Must take a string return the colorized string. Passing this will override any value provided to color parameter.

None
wrap Callable[[str, int], str]

A function to apply your custom wrapping logic. Must take a string and the width and return the wrapped string.

DEFAULT_TEXT_WRAP
Source code in hemline/frame.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def __init__(
    self,
    color: Color | None = None,
    text_alignment: Alignment = DEFAULT_TEXT_ALIGNMENT,
    alignment: Alignment = DEFAULT_FRAME_ALIGNMENT,
    theme: Theme = DEFAULT_THEME,
    horizontal_padding: int = DEFAULT_HORIZONTAL_PADDING,
    vertical_padding: int = DEFAULT_VERTICAL_PADDING,
    outer_width: int = DEFAULT_OUTER_WIDTH,
    container_width: int | None = None,
    colorize: Callable[[str], str] | None = None,
    wrap: Callable[[str, int], str] = DEFAULT_TEXT_WRAP,
) -> None:
    """
    Parameters:
        color: The color of the frame. Use this for colorization out
            of the box. For more sophistaced options, you can pass a
            colorization function to the parameter `colorize`.

        text_alignment: The alignment of the text inside the frame.

        alignment: The alignment of the frame inside the container.

        theme: The appearance of the frameline. Choose one the predefined
            themes from hemline.themes or build your own instance of
            hemline.themes.Theme.

        horizontal_padding: The number of whitespace characters used for
            horizontal padding.

        vertical_padding: The number of blank lines used for vertical
            padding.

        outer_width: The outer width of the Frame, including horizontal
            padding and the frame itself.

        container_width: The width of an imgainary container for the frame,
            resorts to the width of the terminal, if none is provided.

        colorize: A function to apply your custom colorization. Must take a
            string return the colorized string. Passing this will override
            any value provided to `color` parameter.

        wrap: A function to apply your custom wrapping logic. Must take a
            string and the width and return the wrapped string.
    """
    self.text_alignment = text_alignment
    self.alignment = alignment
    self.theme = theme
    self.horizontal_padding = horizontal_padding
    self.vertical_padding = vertical_padding
    self.outer_width = outer_width
    self.container_width = container_width
    if not color:
        self.colorize = colorize
    else:
        self.colorize = colorize or partial(default_colorize, color=color)
    self.wrap = wrap

format

format(text)

Parameters:

Name Type Description Default
text str

The text to frame.

required
Source code in hemline/frame.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def format(self, text: str) -> str:
    """
    Parameters:
        text: The text to frame.
    """
    text = self.wrap(text, self.text_width)
    raw_lines = text.split("\n")
    raw_lines = (
        [""] * self.vertical_padding
        + raw_lines
        + [""] * self.vertical_padding
    )
    top_line = self._border_line(
        left=self.theme.top_left,
        right=self.theme.top_right,
    )
    bottom_line = self._border_line(
        left=self.theme.bottom_left,
        right=self.theme.bottom_right,
    )
    framed_lines = [self._framed_line(text=line) for line in raw_lines]
    return "\n".join([top_line] + framed_lines + [bottom_line])

hemline.frame.Frame.__init__

__init__(
    color=None,
    text_alignment=DEFAULT_TEXT_ALIGNMENT,
    alignment=DEFAULT_FRAME_ALIGNMENT,
    theme=DEFAULT_THEME,
    horizontal_padding=DEFAULT_HORIZONTAL_PADDING,
    vertical_padding=DEFAULT_VERTICAL_PADDING,
    outer_width=DEFAULT_OUTER_WIDTH,
    container_width=None,
    colorize=None,
    wrap=DEFAULT_TEXT_WRAP,
)

Parameters:

Name Type Description Default
color Color | None

The color of the frame. Use this for colorization out of the box. For more sophistaced options, you can pass a colorization function to the parameter colorize.

None
text_alignment Alignment

The alignment of the text inside the frame.

DEFAULT_TEXT_ALIGNMENT
alignment Alignment

The alignment of the frame inside the container.

DEFAULT_FRAME_ALIGNMENT
theme Theme

The appearance of the frameline. Choose one the predefined themes from hemline.themes or build your own instance of hemline.themes.Theme.

DEFAULT_THEME
horizontal_padding int

The number of whitespace characters used for horizontal padding.

DEFAULT_HORIZONTAL_PADDING
vertical_padding int

The number of blank lines used for vertical padding.

DEFAULT_VERTICAL_PADDING
outer_width int

The outer width of the Frame, including horizontal padding and the frame itself.

DEFAULT_OUTER_WIDTH
container_width int | None

The width of an imgainary container for the frame, resorts to the width of the terminal, if none is provided.

None
colorize Callable[[str], str] | None

A function to apply your custom colorization. Must take a string return the colorized string. Passing this will override any value provided to color parameter.

None
wrap Callable[[str, int], str]

A function to apply your custom wrapping logic. Must take a string and the width and return the wrapped string.

DEFAULT_TEXT_WRAP
Source code in hemline/frame.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def __init__(
    self,
    color: Color | None = None,
    text_alignment: Alignment = DEFAULT_TEXT_ALIGNMENT,
    alignment: Alignment = DEFAULT_FRAME_ALIGNMENT,
    theme: Theme = DEFAULT_THEME,
    horizontal_padding: int = DEFAULT_HORIZONTAL_PADDING,
    vertical_padding: int = DEFAULT_VERTICAL_PADDING,
    outer_width: int = DEFAULT_OUTER_WIDTH,
    container_width: int | None = None,
    colorize: Callable[[str], str] | None = None,
    wrap: Callable[[str, int], str] = DEFAULT_TEXT_WRAP,
) -> None:
    """
    Parameters:
        color: The color of the frame. Use this for colorization out
            of the box. For more sophistaced options, you can pass a
            colorization function to the parameter `colorize`.

        text_alignment: The alignment of the text inside the frame.

        alignment: The alignment of the frame inside the container.

        theme: The appearance of the frameline. Choose one the predefined
            themes from hemline.themes or build your own instance of
            hemline.themes.Theme.

        horizontal_padding: The number of whitespace characters used for
            horizontal padding.

        vertical_padding: The number of blank lines used for vertical
            padding.

        outer_width: The outer width of the Frame, including horizontal
            padding and the frame itself.

        container_width: The width of an imgainary container for the frame,
            resorts to the width of the terminal, if none is provided.

        colorize: A function to apply your custom colorization. Must take a
            string return the colorized string. Passing this will override
            any value provided to `color` parameter.

        wrap: A function to apply your custom wrapping logic. Must take a
            string and the width and return the wrapped string.
    """
    self.text_alignment = text_alignment
    self.alignment = alignment
    self.theme = theme
    self.horizontal_padding = horizontal_padding
    self.vertical_padding = vertical_padding
    self.outer_width = outer_width
    self.container_width = container_width
    if not color:
        self.colorize = colorize
    else:
        self.colorize = colorize or partial(default_colorize, color=color)
    self.wrap = wrap

hemline.frame.Frame.format

format(text)

Parameters:

Name Type Description Default
text str

The text to frame.

required
Source code in hemline/frame.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def format(self, text: str) -> str:
    """
    Parameters:
        text: The text to frame.
    """
    text = self.wrap(text, self.text_width)
    raw_lines = text.split("\n")
    raw_lines = (
        [""] * self.vertical_padding
        + raw_lines
        + [""] * self.vertical_padding
    )
    top_line = self._border_line(
        left=self.theme.top_left,
        right=self.theme.top_right,
    )
    bottom_line = self._border_line(
        left=self.theme.bottom_left,
        right=self.theme.bottom_right,
    )
    framed_lines = [self._framed_line(text=line) for line in raw_lines]
    return "\n".join([top_line] + framed_lines + [bottom_line])

Theme

hemline.themes

Theme

Source code in hemline/themes.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Theme:
    def __init__(
        self,
        horizontal: SingleCharacter,
        vertical: SingleCharacter,
        top_left: SingleCharacter,
        top_right: SingleCharacter,
        bottom_left: SingleCharacter,
        bottom_right: SingleCharacter,
    ) -> None:
        """
        Parameters:
            horizontal: single character string.
            vertical: single character string.
            top_left: single character string.
            top_right: single character string.
            bottom_left: single character string.
            bottom_right: single character string.
        """
        self.horizontal = horizontal
        self.vertical = vertical
        self.top_left = top_left
        self.top_right = top_right
        self.bottom_left = bottom_left
        self.bottom_right = bottom_right
        for field in [
            "horizontal",
            "vertical",
            "top_left",
            "top_right",
            "bottom_left",
            "bottom_right",
        ]:
            border = self.__validate_border(field)
            setattr(self, field, border)

    def __validate_border(self, field: str) -> str:
        border = getattr(self, field)
        if not isinstance(border, str):
            raise TypeError(f"Delimiter border `{field}` must be a string.")

        length = len(border)
        if not length == 1:
            raise ValueError(
                "Delimiters must be single characters. "
                f'`{field}` ("{border}") has {length}.'
            )
        return border

__init__

__init__(
    horizontal,
    vertical,
    top_left,
    top_right,
    bottom_left,
    bottom_right,
)

Parameters:

Name Type Description Default
horizontal SingleCharacter

single character string.

required
vertical SingleCharacter

single character string.

required
top_left SingleCharacter

single character string.

required
top_right SingleCharacter

single character string.

required
bottom_left SingleCharacter

single character string.

required
bottom_right SingleCharacter

single character string.

required
Source code in hemline/themes.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def __init__(
    self,
    horizontal: SingleCharacter,
    vertical: SingleCharacter,
    top_left: SingleCharacter,
    top_right: SingleCharacter,
    bottom_left: SingleCharacter,
    bottom_right: SingleCharacter,
) -> None:
    """
    Parameters:
        horizontal: single character string.
        vertical: single character string.
        top_left: single character string.
        top_right: single character string.
        bottom_left: single character string.
        bottom_right: single character string.
    """
    self.horizontal = horizontal
    self.vertical = vertical
    self.top_left = top_left
    self.top_right = top_right
    self.bottom_left = bottom_left
    self.bottom_right = bottom_right
    for field in [
        "horizontal",
        "vertical",
        "top_left",
        "top_right",
        "bottom_left",
        "bottom_right",
    ]:
        border = self.__validate_border(field)
        setattr(self, field, border)

factory

factory(character, corner=None)

Convenience factory for a Theme built from one character, optionally specifying the character used for corners.

Parameters:

Name Type Description Default
character SingleCharacter

The character to use for the frameline. Must be a single-character string.

required
corner SingleCharacter | None

The character to use for the corners, resorts to character if none is provided. Must be a single-character string.

None
Source code in hemline/themes.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def factory(
    character: SingleCharacter, corner: SingleCharacter | None = None
) -> Theme:
    """Convenience factory for a Theme built from one character, optionally
    specifying the character used for corners.

    Parameters:
        character: The character to use for the frameline. Must be a
            single-character string.

        corner: The character to use for the corners, resorts to `character` if
            none is provided. Must be a single-character string.
    """
    corner = corner or character

    return Theme(
        horizontal=character,
        vertical=character,
        top_left=corner,
        top_right=corner,
        bottom_left=corner,
        bottom_right=corner,
    )

hemline.themes.Theme

Source code in hemline/themes.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Theme:
    def __init__(
        self,
        horizontal: SingleCharacter,
        vertical: SingleCharacter,
        top_left: SingleCharacter,
        top_right: SingleCharacter,
        bottom_left: SingleCharacter,
        bottom_right: SingleCharacter,
    ) -> None:
        """
        Parameters:
            horizontal: single character string.
            vertical: single character string.
            top_left: single character string.
            top_right: single character string.
            bottom_left: single character string.
            bottom_right: single character string.
        """
        self.horizontal = horizontal
        self.vertical = vertical
        self.top_left = top_left
        self.top_right = top_right
        self.bottom_left = bottom_left
        self.bottom_right = bottom_right
        for field in [
            "horizontal",
            "vertical",
            "top_left",
            "top_right",
            "bottom_left",
            "bottom_right",
        ]:
            border = self.__validate_border(field)
            setattr(self, field, border)

    def __validate_border(self, field: str) -> str:
        border = getattr(self, field)
        if not isinstance(border, str):
            raise TypeError(f"Delimiter border `{field}` must be a string.")

        length = len(border)
        if not length == 1:
            raise ValueError(
                "Delimiters must be single characters. "
                f'`{field}` ("{border}") has {length}.'
            )
        return border

__init__

__init__(
    horizontal,
    vertical,
    top_left,
    top_right,
    bottom_left,
    bottom_right,
)

Parameters:

Name Type Description Default
horizontal SingleCharacter

single character string.

required
vertical SingleCharacter

single character string.

required
top_left SingleCharacter

single character string.

required
top_right SingleCharacter

single character string.

required
bottom_left SingleCharacter

single character string.

required
bottom_right SingleCharacter

single character string.

required
Source code in hemline/themes.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def __init__(
    self,
    horizontal: SingleCharacter,
    vertical: SingleCharacter,
    top_left: SingleCharacter,
    top_right: SingleCharacter,
    bottom_left: SingleCharacter,
    bottom_right: SingleCharacter,
) -> None:
    """
    Parameters:
        horizontal: single character string.
        vertical: single character string.
        top_left: single character string.
        top_right: single character string.
        bottom_left: single character string.
        bottom_right: single character string.
    """
    self.horizontal = horizontal
    self.vertical = vertical
    self.top_left = top_left
    self.top_right = top_right
    self.bottom_left = bottom_left
    self.bottom_right = bottom_right
    for field in [
        "horizontal",
        "vertical",
        "top_left",
        "top_right",
        "bottom_left",
        "bottom_right",
    ]:
        border = self.__validate_border(field)
        setattr(self, field, border)

hemline.themes.single module-attribute

single = Theme(
    horizontal="─",
    vertical="│",
    top_left="┌",
    top_right="┐",
    bottom_left="└",
    bottom_right="┘",
)

hemline.themes.double module-attribute

double = Theme(
    horizontal="═",
    vertical="║",
    top_left="╔",
    top_right="╗",
    bottom_left="╚",
    bottom_right="╝",
)

hemline.themes.dotted module-attribute

dotted = factory('·')

hemline.themes.none module-attribute

none = factory(' ')

hemline.themes.factory

factory(character, corner=None)

Convenience factory for a Theme built from one character, optionally specifying the character used for corners.

Parameters:

Name Type Description Default
character SingleCharacter

The character to use for the frameline. Must be a single-character string.

required
corner SingleCharacter | None

The character to use for the corners, resorts to character if none is provided. Must be a single-character string.

None
Source code in hemline/themes.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def factory(
    character: SingleCharacter, corner: SingleCharacter | None = None
) -> Theme:
    """Convenience factory for a Theme built from one character, optionally
    specifying the character used for corners.

    Parameters:
        character: The character to use for the frameline. Must be a
            single-character string.

        corner: The character to use for the corners, resorts to `character` if
            none is provided. Must be a single-character string.
    """
    corner = corner or character

    return Theme(
        horizontal=character,
        vertical=character,
        top_left=corner,
        top_right=corner,
        bottom_left=corner,
        bottom_right=corner,
    )

Other

hemline.alignment.Alignment module-attribute

Alignment = Literal['left', 'center', 'right']

hemline.colors

Color

Bases: StrEnum

Source code in hemline/colors.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
class Color(StrEnum):
    BLACK = "\033[0;30m"
    DARK_RED = "\033[0;31m"
    DARK_GREEN = "\033[0;32m"
    BROWN = "\033[1;33m"
    DARK_BLUE = "\033[0;34m"
    PURPLE = "\033[0;35m"
    TEAL = "\033[0;36m"
    LIGHT_GRAY = "\033[0;37m"
    DARK_GRAY = "\033[1;90m"
    RED = "\033[0;92m"
    GREEN = "\033[0;92m"
    YELLOW = "\033[;93m"
    BLUE = "\033[0;94m"
    MAGENTA = "\033[;95m"
    CYAN = "\033[0;96m"
    WHITE = "\033[;97m"
    RESET = "\033[0m"

BLACK class-attribute instance-attribute

BLACK = '\x1b[0;30m'

BLUE class-attribute instance-attribute

BLUE = '\x1b[0;94m'

BROWN class-attribute instance-attribute

BROWN = '\x1b[1;33m'

CYAN class-attribute instance-attribute

CYAN = '\x1b[0;96m'

DARK_BLUE class-attribute instance-attribute

DARK_BLUE = '\x1b[0;34m'

DARK_GRAY class-attribute instance-attribute

DARK_GRAY = '\x1b[1;90m'

DARK_GREEN class-attribute instance-attribute

DARK_GREEN = '\x1b[0;32m'

DARK_RED class-attribute instance-attribute

DARK_RED = '\x1b[0;31m'

GREEN class-attribute instance-attribute

GREEN = '\x1b[0;92m'

LIGHT_GRAY class-attribute instance-attribute

LIGHT_GRAY = '\x1b[0;37m'

MAGENTA class-attribute instance-attribute

MAGENTA = '\x1b[;95m'

PURPLE class-attribute instance-attribute

PURPLE = '\x1b[0;35m'

RED class-attribute instance-attribute

RED = '\x1b[0;92m'

RESET class-attribute instance-attribute

RESET = '\x1b[0m'

TEAL class-attribute instance-attribute

TEAL = '\x1b[0;36m'

WHITE class-attribute instance-attribute

WHITE = '\x1b[;97m'

YELLOW class-attribute instance-attribute

YELLOW = '\x1b[;93m'

default_colorize

default_colorize(text, color)

Parameters:

Name Type Description Default
text str

The text to colorize

required
color Color

The Color to use.

required
Source code in hemline/colors.py
24
25
26
27
28
29
30
31
def default_colorize(text: str, color: Color) -> str:
    """
    Parameters:
        text: The text to colorize

        color: The Color to use.
    """
    return f"{color}{text}{Color.RESET}"

hemline.defaults

DEFAULT_FRAME_ALIGNMENT module-attribute

DEFAULT_FRAME_ALIGNMENT = 'center'

DEFAULT_HORIZONTAL_PADDING module-attribute

DEFAULT_HORIZONTAL_PADDING = 4

DEFAULT_OUTER_WIDTH module-attribute

DEFAULT_OUTER_WIDTH = (
    88 + 2 * DEFAULT_HORIZONTAL_PADDING + 2
)

DEFAULT_TEXT_ALIGNMENT module-attribute

DEFAULT_TEXT_ALIGNMENT = 'left'

DEFAULT_TEXT_WRAP module-attribute

DEFAULT_TEXT_WRAP = wrap

DEFAULT_THEME module-attribute

DEFAULT_THEME = single

DEFAULT_VERTICAL_PADDING module-attribute

DEFAULT_VERTICAL_PADDING = 1