File: _lazy_rich.py

package info (click to toggle)
python-rich-argparse 1.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 2,224; makefile: 3
file content (73 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download
1
2
3
4
5
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# for internal use only
from __future__ import annotations

TYPE_CHECKING = False
if TYPE_CHECKING:
    from typing import Any

    from rich.ansi import re_ansi as re_ansi
    from rich.console import Console as Console
    from rich.console import ConsoleOptions as ConsoleOptions
    from rich.console import RenderableType as RenderableType
    from rich.console import RenderResult as RenderResult
    from rich.containers import Lines as Lines
    from rich.control import strip_control_codes as strip_control_codes
    from rich.markup import escape as escape
    from rich.padding import Padding as Padding
    from rich.segment import Segment as Segment
    from rich.style import StyleType as StyleType
    from rich.text import Span as Span
    from rich.text import Text as Text
    from rich.theme import Theme as Theme

__all__ = [
    "re_ansi",
    "Console",
    "ConsoleOptions",
    "RenderableType",
    "RenderResult",
    "Lines",
    "strip_control_codes",
    "escape",
    "Padding",
    "Segment",
    "StyleType",
    "Span",
    "Text",
    "Theme",
]


def __getattr__(name: str) -> Any:
    if name not in __all__:
        raise AttributeError(name)
    import rich.ansi
    import rich.console
    import rich.containers
    import rich.control
    import rich.markup
    import rich.padding
    import rich.segment
    import rich.style
    import rich.text
    import rich.theme

    globals().update(
        {
            "re_ansi": rich.ansi.re_ansi,
            "Console": rich.console.Console,
            "ConsoleOptions": rich.console.ConsoleOptions,
            "RenderableType": rich.console.RenderableType,
            "RenderResult": rich.console.RenderResult,
            "Lines": rich.containers.Lines,
            "strip_control_codes": rich.control.strip_control_codes,
            "escape": rich.markup.escape,
            "Padding": rich.padding.Padding,
            "Segment": rich.segment.Segment,
            "StyleType": rich.style.StyleType,
            "Span": rich.text.Span,
            "Text": rich.text.Text,
            "Theme": rich.theme.Theme,
        }
    )
    return globals()[name]