Method: rich.console.Console.__init__
Calls: 337, Exceptions: 0, Paths: 47Back
Path 1: 90 calls (0.27)
'auto' (90)
None (90)
None (90)
None (90)
False (90)
None (90)
False (90)
None (66) StringIO (23) TextIOWrapper (1)
False (89) True (1)
None (90)
None (90)
None (90)
None (90)
8 (90)
False (75) True (15)
True (89) False (1)
True (89) False (1)
None (90)
True (90)
True (90)
True (90)
'[%X]' (90)
ReprHighlighter (90)
None (90)
True (90)
None (89) test_get_time.
None (89) test_get_time.
None (90)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 2: 51 calls (0.15)
'auto' (51)
None (51)
None (51)
None (51)
False (51)
None (51)
False (51)
StringIO (35) None (16)
False (51)
100 (19) 10 (12) 20 (3) 3 (3) 5 (3) 40 (2) 120 (2) 42 (2) 2 (2) 4 (1)
None (51)
None (51)
None (51)
8 (51)
False (33) True (18)
True (51)
True (51)
None (51)
True (51)
True (51)
True (50) False (1)
'[%X]' (50) test_log_milliseconds.
ReprHighlighter (51)
None (51)
True (51)
None (51)
None (51)
None (51)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 3: 24 calls (0.07)
'truecolor' (24)
None (24)
None (24)
None (24)
False (24)
None (24)
False (24)
StringIO (24)
False (24)
100 (23) 20 (1)
None (24)
None (24)
None (24)
8 (24)
False (23) True (1)
True (24)
True (24)
None (24)
True (24)
True (24)
True (24)
'[%X]' (24)
ReprHighlighter (24)
False (24)
True (24)
None (24)
None (24)
None (24)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 4: 24 calls (0.07)
'auto' (24)
None (24)
None (24)
None (24)
False (24)
None (24)
False (24)
StringIO (24)
False (24)
50 (22) 100 (2)
None (24)
None (24)
None (24)
8 (24)
False (24)
True (24)
True (24)
None (24)
True (24)
True (24)
True (24)
'[%X]' (24)
ReprHighlighter (24)
False (24)
True (24)
None (24)
None (24)
None (24)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 5: 15 calls (0.04)
'truecolor' (13) 'standard' (1) 'windows' (1)
None (15)
None (15)
None (15)
False (15)
None (15)
False (15)
StringIO (13) None (2)
False (15)
None (15)
None (15)
None (15)
None (15)
8 (15)
False (15)
True (15)
True (15)
None (15)
True (15)
True (15)
True (15)
'[%X]' (15)
ReprHighlighter (15)
None (15)
True (15)
None (15)
None (15)
None (15)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 6: 10 calls (0.03)
None (10)
None (10)
None (10)
None (10)
False (10)
None (10)
False (10)
None (10)
False (10)
None (10)
None (10)
None (10)
None (10)
8 (10)
False (10)
True (10)
True (10)
None (10)
True (10)
True (10)
True (10)
'[%X]' (10)
ReprHighlighter (10)
None (10)
True (10)
None (10)
None (10)
None (10)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 7: 10 calls (0.03)
'truecolor' (10)
True (10)
None (10)
None (10)
False (10)
None (10)
False (10)
StringIO (10)
False (10)
60 (5) 80 (3) 10 (2)
None (10)
None (10)
None (10)
8 (10)
False (10)
True (10)
True (10)
None (10)
True (10)
True (10)
True (10)
'[%X]' (10)
ReprHighlighter (10)
False (10)
True (10)
None (10)
None (10)
{} (10)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 8: 9 calls (0.03)
'auto' (9)
True (9)
None (9)
None (9)
False (9)
None (8) Theme (1)
False (9)
None (6) StringIO (3)
False (9)
None (9)
None (9)
None (9)
None (9)
8 (9)
False (9)
True (9)
True (9)
None (9)
True (9)
True (9)
True (9)
'[%X]' (9)
ReprHighlighter (9)
None (9)
True (9)
None (9)
None (9)
{} (6) {'TERM': 'dumb'} (1) {'TERM': 'rxvt-unicode-256color'} (1) {'COLORTERM': 'truecolor'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 9: 9 calls (0.03)
None (9)
True (8) False (1)
None (9)
None (9)
False (9)
None (9)
False (9)
None (9)
False (9)
60 (8) 20 (1)
5 (5) 80 (4)
None (9)
None (9)
8 (9)
False (9)
True (9)
True (9)
None (9)
True (9)
True (9)
True (9)
'[%X]' (9)
ReprHighlighter (9)
False (9)
True (9)
None (9)
None (9)
{} (9)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 10: 7 calls (0.02)
'auto' (7)
None (7)
None (7)
None (7)
False (7)
None (7)
False (7)
None (6) StringIO (1)
False (7)
None (7)
None (7)
None (7)
None (7)
8 (7)
False (7)
True (7)
True (7)
None (7)
True (7)
True (7)
True (7)
'[%X]' (7)
ReprHighlighter (7)
False (7)
True (7)
None (7)
None (7)
None (7)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 11: 7 calls (0.02)
'auto' (7)
None (7)
True (7)
None (7)
False (7)
None (7)
False (7)
StringIO (6) None (1)
False (7)
None (7)
None (7)
None (7)
None (7)
8 (7)
False (7)
True (7)
True (7)
None (7)
True (7)
True (7)
True (7)
'[%X]' (7)
ReprHighlighter (7)
None (7)
True (7)
None (7)
None (7)
None (7)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 12: 7 calls (0.02)
None (7)
None (7)
None (7)
None (7)
False (7)
None (7)
False (7)
None (6) StringIO (1)
False (7)
100 (3) 60 (2) 20 (1) 80 (1)
None (7)
None (7)
None (7)
8 (7)
False (7)
True (7)
True (7)
None (7)
True (7)
True (6) False (1)
True (6) False (1)
'[%X]' (7)
ReprHighlighter (7)
None (7)
True (7)
None (7)
None (7)
None (7)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 13: 6 calls (0.02)
'auto' (6)
None (6)
None (6)
None (6)
False (6)
None (6)
False (6)
StringIO (6)
False (6)
32 (4) 16 (2)
None (6)
None (6)
None (6)
8 (6)
False (6)
True (6)
True (6)
None (6)
True (6)
True (6)
True (6)
'[%X]' (6)
ReprHighlighter (6)
False (6)
True (6)
None (6)
None (6)
{} (6)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 14: 5 calls (0.01)
'auto' (5)
True (5)
None (5)
None (5)
False (5)
None (5)
False (5)
StringIO (5)
False (5)
20 (2) 10 (2) 16 (1)
None (5)
None (5)
None (5)
8 (5)
False (5)
True (5)
True (5)
None (5)
True (5)
True (5)
True (5)
'[%X]' (5)
ReprHighlighter (5)
False (5)
True (5)
None (5)
None (5)
{} (5)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 15: 4 calls (0.01)
'auto' (4)
True (4)
None (4)
None (4)
False (4)
None (4)
False (4)
None (3) StringIO (1)
False (4)
None (4)
None (4)
None (4)
None (4)
8 (4)
False (4)
True (4)
True (4)
None (4)
True (4)
True (4)
True (4)
'[%X]' (4)
ReprHighlighter (4)
False (4)
True (4)
None (4)
None (4)
{'TERM': 'xterm-16color'} (1) {'COLORTERM': 'truecolor', 'TERM': 'xterm-16color'} (1) {'TERM': 'xterm-kitty'} (1) {} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 16: 4 calls (0.01)
'auto' (4)
True (4)
None (4)
None (4)
False (4)
None (4)
False (4)
StringIO (3) None (1)
False (4)
20 (4)
None (4)
None (4)
None (4)
8 (4)
False (4)
True (4)
True (4)
None (4)
True (4)
True (4)
True (4)
'[%X]' (4)
ReprHighlighter (4)
None (4)
True (4)
None (4)
None (3) test_spinner_update.
{} (4)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 17: 4 calls (0.01)
None (4)
True (4)
None (4)
None (4)
False (4)
None (4)
False (4)
StringIO (3) None (1)
False (4)
16 (2) 80 (1) 60 (1)
None (4)
None (4)
None (4)
8 (4)
False (4)
True (4)
True (4)
None (4)
True (4)
True (4)
True (4)
'[%X]' (4)
ReprHighlighter (4)
False (4)
True (4)
None (4)
None (4)
{} (4)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 18: 3 calls (0.01)
'truecolor' (3)
True (3)
None (3)
None (3)
False (3)
None (3)
False (3)
StringIO (3)
False (3)
80 (1) 10 (1) 140 (1)
None (3)
None (3)
None (3)
8 (3)
False (3)
True (3)
True (3)
None (3)
True (3)
True (3)
True (3)
'[%X]' (3)
ReprHighlighter (3)
None (3)
True (3)
None (3)
None (3)
{} (3)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 19: 3 calls (0.01)
'auto' (3)
None (3)
None (3)
None (3)
False (3)
None (3)
False (3)
None (3)
False (3)
99 (1) 80 (1) 63 (1)
101 (1) 25 (1) 46 (1)
None (3)
None (3)
8 (3)
False (3)
True (3)
True (3)
None (3)
True (3)
True (3)
True (3)
'[%X]' (3)
ReprHighlighter (3)
False (3)
True (3)
None (3)
None (3)
None (3)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 20: 3 calls (0.01)
'auto' (3)
None (3)
None (3)
None (3)
False (3)
None (3)
False (3)
None (3)
False (3)
None (3)
None (3)
None (3)
None (3)
8 (3)
False (3)
True (3)
True (3)
None (3)
True (3)
True (3)
True (3)
'[%X]' (3)
ReprHighlighter (3)
None (3)
True (3)
None (3)
None (3)
{} (3)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 21: 3 calls (0.01)
'auto' (3)
None (3)
None (3)
None (3)
False (3)
None (3)
False (3)
StringIO (3)
False (3)
None (3)
None (3)
None (3)
None (3)
8 (3)
False (3)
True (3)
True (3)
None (3)
True (3)
True (3)
True (3)
'[%X]' (3)
ReprHighlighter (3)
None (3)
True (3)
None (3)
None (3)
{'FORCE_COLOR': ''} (1) {'FORCE_COLOR': 'something'} (1) {'FORCE_COLOR': '0'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 22: 3 calls (0.01)
'auto' (3)
None (3)
True (3)
None (3)
False (3)
None (3)
False (3)
None (3)
False (3)
40 (3)
None (3)
None (3)
None (3)
8 (3)
False (3)
True (3)
True (3)
None (3)
True (3)
True (3)
True (3)
'[%X]' (3)
ReprHighlighter (3)
None (3)
True (3)
None (3)
None (3)
{'JUPYTER_COLUMNS': '314'} (1) {'JUPYTER_COLUMNS': 'broken'} (1) {'JUPYTER_LINES': 'broken'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 23: 2 calls (0.01)
'truecolor' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
None (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
False (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 24: 2 calls (0.01)
'auto' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
StringIO (2)
False (2)
20 (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 25: 2 calls (0.01)
'truecolor' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
StringIO (2)
False (2)
None (2)
None (2)
'red' (1) None (1)
None (1) True (1)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 26: 2 calls (0.01)
'auto' (2)
None (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
80 (2)
46 (1) 25 (1)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 27: 2 calls (0.01)
'auto' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
None (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 28: 2 calls (0.01)
'auto' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
20 (2)
5 (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
{} (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 29: 2 calls (0.01)
'truecolor' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
20 (2)
40 (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
False (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 30: 2 calls (0.01)
'truecolor' (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
StringIO (1) None (1)
False (2)
80 (2)
None (2)
None (2)
None (2)
8 (2)
False (1) True (1)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[TIME]' (1) '[%X]' (1)
ReprHighlighter (2)
False (2)
True (2)
None (2)
None (2)
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 31: 2 calls (0.01)
None (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
StringIO (2)
False (2)
140 (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
None (2)
{} (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 32: 2 calls (0.01)
None (2)
True (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
80 (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
None (2)
True (2)
None (2)
test_spinner_render.
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 33: 2 calls (0.01)
None (2)
None (2)
None (2)
None (2)
False (2)
None (2)
False (2)
None (2)
False (2)
80 (2)
None (2)
None (2)
None (2)
8 (2)
False (2)
True (2)
True (2)
None (2)
True (2)
True (2)
True (2)
'[%X]' (2)
ReprHighlighter (2)
False (2)
True (2)
None (2)
test_status.
None (2)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 34: 1 calls (0.0)
None (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
6 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
None (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 35: 1 calls (0.0)
'truecolor' (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
StringIO (1)
False (1)
80 (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
False (1)
'TIME' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 36: 1 calls (0.0)
None (1)
True (1)
None (1)
True (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 37: 1 calls (0.0)
'truecolor' (1)
True (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
20 (1)
4 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 38: 1 calls (0.0)
'auto' (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'LINES': '220'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 39: 1 calls (0.0)
'auto' (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
40 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'LINES': '220'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 40: 1 calls (0.0)
'auto' (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
40 (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'LINES': 'broken'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 41: 1 calls (0.0)
'auto' (1)
True (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
20 (1)
5 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
None (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 42: 1 calls (0.0)
'auto' (1)
None (1)
True (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'JUPYTER_COLUMNS': '314'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 43: 1 calls (0.0)
'auto' (1)
None (1)
True (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'JUPYTER_LINES': '220'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 44: 1 calls (0.0)
'auto' (1)
None (1)
True (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
None (1)
40 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
{'JUPYTER_LINES': '220'} (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 45: 1 calls (0.0)
None (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
20 (1)
5 (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
False (1)
True (1)
None (1)
None (1)
None (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 46: 1 calls (0.0)
'truecolor' (1)
True (1)
None (1)
None (1)
False (1)
None (1)
False (1)
StringIO (1)
False (1)
30 (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
None (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False
Path 47: 1 calls (0.0)
'truecolor' (1)
None (1)
None (1)
None (1)
False (1)
None (1)
False (1)
None (1)
False (1)
100 (1)
None (1)
None (1)
None (1)
8 (1)
False (1)
True (1)
True (1)
None (1)
True (1)
True (1)
True (1)
'[%X]' (1)
ReprHighlighter (1)
None (1)
True (1)
None (1)
None (1)
None (1)
1def __init__(
2 self,
3 *,
4 color_system: Optional[
5 Literal["auto", "standard", "256", "truecolor", "windows"]
6 ] = "auto",
7 force_terminal: Optional[bool] = None,
8 force_jupyter: Optional[bool] = None,
9 force_interactive: Optional[bool] = None,
10 soft_wrap: bool = False,
11 theme: Optional[Theme] = None,
12 stderr: bool = False,
13 file: Optional[IO[str]] = None,
14 quiet: bool = False,
15 width: Optional[int] = None,
16 height: Optional[int] = None,
17 style: Optional[StyleType] = None,
18 no_color: Optional[bool] = None,
19 tab_size: int = 8,
20 record: bool = False,
21 markup: bool = True,
22 emoji: bool = True,
23 emoji_variant: Optional[EmojiVariant] = None,
24 highlight: bool = True,
25 log_time: bool = True,
26 log_path: bool = True,
27 log_time_format: Union[str, FormatTimeCallable] = "[%X]",
28 highlighter: Optional["HighlighterType"] = ReprHighlighter(),
29 legacy_windows: Optional[bool] = None,
30 safe_box: bool = True,
31 get_datetime: Optional[Callable[[], datetime]] = None,
32 get_time: Optional[Callable[[], float]] = None,
33 _environ: Optional[Mapping[str, str]] = None,
34 ):
35 # Copy of os.environ allows us to replace it for testing
36 if _environ is not None:
37 self._environ = _environ
38
39 self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter
40 if self.is_jupyter:
41 if width is None:
42 jupyter_columns = self._environ.get("JUPYTER_COLUMNS")
43 if jupyter_columns is not None and jupyter_columns.isdigit():
44 width = int(jupyter_columns)
45 else:
46 width = JUPYTER_DEFAULT_COLUMNS
47 if height is None:
48 jupyter_lines = self._environ.get("JUPYTER_LINES")
49 if jupyter_lines is not None and jupyter_lines.isdigit():
50 height = int(jupyter_lines)
51 else:
52 height = JUPYTER_DEFAULT_LINES
53
54 self.tab_size = tab_size
55 self.record = record
56 self._markup = markup
57 self._emoji = emoji
58 self._emoji_variant: Optional[EmojiVariant] = emoji_variant
59 self._highlight = highlight
60 self.legacy_windows: bool = (
61 (detect_legacy_windows() and not self.is_jupyter)
62 if legacy_windows is None
63 else legacy_windows
64 )
65
66 if width is None:
67 columns = self._environ.get("COLUMNS")
68 if columns is not None and columns.isdigit():
69 width = int(columns) - self.legacy_windows
70 if height is None:
71 lines = self._environ.get("LINES")
72 if lines is not None and lines.isdigit():
73 height = int(lines)
74
75 self.soft_wrap = soft_wrap
76 self._width = width
77 self._height = height
78
79 self._color_system: Optional[ColorSystem]
80
81 self._force_terminal = None
82 if force_terminal is not None:
83 self._force_terminal = force_terminal
84 else:
85 # If FORCE_COLOR env var has any value at all, we force terminal.
86 force_color = self._environ.get("FORCE_COLOR")
87 if force_color is not None:
88 self._force_terminal = True
89
90 self._file = file
91 self.quiet = quiet
92 self.stderr = stderr
93
94 if color_system is None:
95 self._color_system = None
96 elif color_system == "auto":
97 self._color_system = self._detect_color_system()
98 else:
99 self._color_system = COLOR_SYSTEMS[color_system]
100
101 self._lock = threading.RLock()
102 self._log_render = LogRender(
103 show_time=log_time,
104 show_path=log_path,
105 time_format=log_time_format,
106 )
107 self.highlighter: HighlighterType = highlighter or _null_highlighter
108 self.safe_box = safe_box
109 self.get_datetime = get_datetime or datetime.now
110 self.get_time = get_time or monotonic
111 self.style = style
112 self.no_color = (
113 no_color if no_color is not None else "NO_COLOR" in self._environ
114 )
115 self.is_interactive = (
116 (self.is_terminal and not self.is_dumb_terminal)
117 if force_interactive is None
118 else force_interactive
119 )
120
121 self._record_buffer_lock = threading.RLock()
122 self._thread_locals = ConsoleThreadLocals(
123 theme_stack=ThemeStack(themes.DEFAULT if theme is None else theme)
124 )
125 self._record_buffer: List[Segment] = []
126 self._render_hooks: List[RenderHook] = []
127 self._live: Optional["Live"] = None
128 self._is_alt_screen = False