Skip to content

Commit 1b4c1ea

Browse files
committed
fixup! fixup! fixup! fixup! Update _colorize.py
1 parent 1ac9a48 commit 1b4c1ea

3 files changed

Lines changed: 60 additions & 55 deletions

File tree

Lib/_colorize.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -200,42 +200,6 @@ class Difflib(ThemeSection):
200200
reset: str = ANSIColors.RESET
201201

202202

203-
@dataclass(frozen=True, kw_only=True)
204-
class Syntax(ThemeSection):
205-
prompt: str = ANSIColors.BOLD_MAGENTA
206-
keyword: str = ANSIColors.BOLD_BLUE
207-
keyword_constant: str = ANSIColors.BOLD_BLUE
208-
builtin: str = ANSIColors.CYAN
209-
comment: str = ANSIColors.RED
210-
string: str = ANSIColors.GREEN
211-
number: str = ANSIColors.YELLOW
212-
op: str = ANSIColors.RESET
213-
definition: str = ANSIColors.BOLD
214-
soft_keyword: str = ANSIColors.BOLD_BLUE
215-
reset: str = ANSIColors.RESET
216-
217-
218-
@dataclass(frozen=True, kw_only=True)
219-
class Traceback(ThemeSection):
220-
type: str = ANSIColors.BOLD_MAGENTA
221-
message: str = ANSIColors.MAGENTA
222-
filename: str = ANSIColors.MAGENTA
223-
line_no: str = ANSIColors.MAGENTA
224-
frame: str = ANSIColors.MAGENTA
225-
error_highlight: str = ANSIColors.BOLD_RED
226-
error_range: str = ANSIColors.RED
227-
reset: str = ANSIColors.RESET
228-
229-
230-
@dataclass(frozen=True, kw_only=True)
231-
class Unittest(ThemeSection):
232-
passed: str = ANSIColors.GREEN
233-
warn: str = ANSIColors.YELLOW
234-
fail: str = ANSIColors.RED
235-
fail_info: str = ANSIColors.BOLD_RED
236-
reset: str = ANSIColors.RESET
237-
238-
239203
@dataclass(frozen=True, kw_only=True)
240204
class LiveProfiler(ThemeSection):
241205
"""Theme section for the live profiling TUI (Tachyon profiler).
@@ -344,6 +308,42 @@ class LiveProfiler(ThemeSection):
344308
)
345309

346310

311+
@dataclass(frozen=True, kw_only=True)
312+
class Syntax(ThemeSection):
313+
prompt: str = ANSIColors.BOLD_MAGENTA
314+
keyword: str = ANSIColors.BOLD_BLUE
315+
keyword_constant: str = ANSIColors.BOLD_BLUE
316+
builtin: str = ANSIColors.CYAN
317+
comment: str = ANSIColors.RED
318+
string: str = ANSIColors.GREEN
319+
number: str = ANSIColors.YELLOW
320+
op: str = ANSIColors.RESET
321+
definition: str = ANSIColors.BOLD
322+
soft_keyword: str = ANSIColors.BOLD_BLUE
323+
reset: str = ANSIColors.RESET
324+
325+
326+
@dataclass(frozen=True, kw_only=True)
327+
class Traceback(ThemeSection):
328+
type: str = ANSIColors.BOLD_MAGENTA
329+
message: str = ANSIColors.MAGENTA
330+
filename: str = ANSIColors.MAGENTA
331+
line_no: str = ANSIColors.MAGENTA
332+
frame: str = ANSIColors.MAGENTA
333+
error_highlight: str = ANSIColors.BOLD_RED
334+
error_range: str = ANSIColors.RED
335+
reset: str = ANSIColors.RESET
336+
337+
338+
@dataclass(frozen=True, kw_only=True)
339+
class Unittest(ThemeSection):
340+
passed: str = ANSIColors.GREEN
341+
warn: str = ANSIColors.YELLOW
342+
fail: str = ANSIColors.RED
343+
fail_info: str = ANSIColors.BOLD_RED
344+
reset: str = ANSIColors.RESET
345+
346+
347347
@dataclass(frozen=True, kw_only=True)
348348
class Theme:
349349
"""A suite of themes for all sections of Python.

Lib/profiling/sampling/live_collector/collector.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
FINISHED_BANNER_EXTRA_LINES,
3333
DEFAULT_SORT_BY,
3434
DEFAULT_DISPLAY_LIMIT,
35+
COLOR_PAIR_SAMPLES,
36+
COLOR_PAIR_FILE,
37+
COLOR_PAIR_FUNC,
3538
COLOR_PAIR_HEADER_BG,
3639
COLOR_PAIR_CYAN,
3740
COLOR_PAIR_YELLOW,
@@ -532,36 +535,35 @@ def _setup_colors(self):
532535

533536
if self.display.has_colors() and self._can_colorize:
534537
with contextlib.suppress(Exception):
535-
theme = _colorize.get_theme(force_color=True)
536-
profiler_theme = theme.live_profiler
538+
theme = _colorize.get_theme(force_color=True).live_profiler
537539
default_bg = -1
538540

539-
self.display.init_color_pair(1, profiler_theme.samples_fg, default_bg)
540-
self.display.init_color_pair(2, profiler_theme.file_fg, default_bg)
541-
self.display.init_color_pair(3, profiler_theme.func_fg, default_bg)
541+
self.display.init_color_pair(COLOR_PAIR_SAMPLES, theme.samples_fg, default_bg)
542+
self.display.init_color_pair(COLOR_PAIR_FILE, theme.file_fg, default_bg)
543+
self.display.init_color_pair(COLOR_PAIR_FUNC, theme.func_fg, default_bg)
542544

543545
# Normal header background color pair
544546
self.display.init_color_pair(
545547
COLOR_PAIR_HEADER_BG,
546-
profiler_theme.normal_header_fg,
547-
profiler_theme.normal_header_bg,
548+
theme.normal_header_fg,
549+
theme.normal_header_bg,
548550
)
549551

550-
self.display.init_color_pair(COLOR_PAIR_CYAN, profiler_theme.pid_fg, default_bg)
551-
self.display.init_color_pair(COLOR_PAIR_YELLOW, profiler_theme.time_fg, default_bg)
552-
self.display.init_color_pair(COLOR_PAIR_GREEN, profiler_theme.uptime_fg, default_bg)
553-
self.display.init_color_pair(COLOR_PAIR_MAGENTA, profiler_theme.interval_fg, default_bg)
554-
self.display.init_color_pair(COLOR_PAIR_RED, profiler_theme.off_gil_fg, default_bg)
552+
self.display.init_color_pair(COLOR_PAIR_CYAN, theme.pid_fg, default_bg)
553+
self.display.init_color_pair(COLOR_PAIR_YELLOW, theme.time_fg, default_bg)
554+
self.display.init_color_pair(COLOR_PAIR_GREEN, theme.uptime_fg, default_bg)
555+
self.display.init_color_pair(COLOR_PAIR_MAGENTA, theme.interval_fg, default_bg)
556+
self.display.init_color_pair(COLOR_PAIR_RED, theme.off_gil_fg, default_bg)
555557
self.display.init_color_pair(
556558
COLOR_PAIR_SORTED_HEADER,
557-
profiler_theme.sorted_header_fg,
558-
profiler_theme.sorted_header_bg,
559+
theme.sorted_header_fg,
560+
theme.sorted_header_bg,
559561
)
560562

561563
TREND_UP_PAIR = 11
562564
TREND_DOWN_PAIR = 12
563-
self.display.init_color_pair(TREND_UP_PAIR, profiler_theme.trend_up_fg, default_bg)
564-
self.display.init_color_pair(TREND_DOWN_PAIR, profiler_theme.trend_down_fg, default_bg)
565+
self.display.init_color_pair(TREND_UP_PAIR, theme.trend_up_fg, default_bg)
566+
self.display.init_color_pair(TREND_DOWN_PAIR, theme.trend_down_fg, default_bg)
565567

566568
return {
567569
"header": self.display.get_color_pair(COLOR_PAIR_HEADER_BG) | A_BOLD,
@@ -572,9 +574,9 @@ def _setup_colors(self):
572574
"red": self.display.get_color_pair(COLOR_PAIR_RED) | A_BOLD,
573575
"sorted_header": self.display.get_color_pair(COLOR_PAIR_SORTED_HEADER) | A_BOLD,
574576
"normal_header": self.display.get_color_pair(COLOR_PAIR_HEADER_BG) | A_BOLD,
575-
"color_samples": self.display.get_color_pair(1),
576-
"color_file": self.display.get_color_pair(2),
577-
"color_func": self.display.get_color_pair(3),
577+
"color_samples": self.display.get_color_pair(COLOR_PAIR_SAMPLES),
578+
"color_file": self.display.get_color_pair(COLOR_PAIR_FILE),
579+
"color_func": self.display.get_color_pair(COLOR_PAIR_FUNC),
578580
"trend_up": self.display.get_color_pair(TREND_UP_PAIR) | A_BOLD,
579581
"trend_down": self.display.get_color_pair(TREND_DOWN_PAIR) | A_BOLD,
580582
"trend_stable": A_NORMAL,

Lib/profiling/sampling/live_collector/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
FINISHED_BANNER_EXTRA_LINES = 3 # Blank line + banner + blank line
4747

4848
# Color pair IDs
49+
COLOR_PAIR_SAMPLES = 1
50+
COLOR_PAIR_FILE = 2
51+
COLOR_PAIR_FUNC = 3
4952
COLOR_PAIR_HEADER_BG = 4
5053
COLOR_PAIR_CYAN = 5
5154
COLOR_PAIR_YELLOW = 6

0 commit comments

Comments
 (0)