@@ -200,6 +200,88 @@ class Difflib(ThemeSection):
200200 reset : str = ANSIColors .RESET
201201
202202
203+ @dataclass (frozen = True , kw_only = True )
204+ class Dis (ThemeSection ):
205+ label_bg : str = ANSIColors .BACKGROUND_BLUE
206+ label_fg : str = ANSIColors .BLACK
207+ exception_label : str = ANSIColors .CYAN
208+ argument_detail : str = ANSIColors .GREY
209+
210+ op_stack : str = ANSIColors .BOLD_YELLOW
211+ op_load_store : str = ANSIColors .BOLD_CYAN
212+ op_call_return : str = ANSIColors .BOLD_MAGENTA
213+ op_binary_unary : str = ANSIColors .BOLD_BLUE
214+ op_control_flow : str = ANSIColors .BOLD_GREEN
215+ op_build : str = ANSIColors .BOLD_WHITE
216+ op_exceptions : str = ANSIColors .BOLD_RED
217+ op_other : str = ANSIColors .GREY
218+
219+ reset : str = ANSIColors .RESET
220+
221+ def color_by_opname (self , opname : str ) -> str :
222+ if opname in (
223+ "POP_TOP" ,
224+ "POP_ITER" ,
225+ "END_FOR" ,
226+ "END_SEND" ,
227+ "COPY" ,
228+ "SWAP" ,
229+ "PUSH_NULL" ,
230+ "PUSH_EXC_INFO" ,
231+ "NOP" ,
232+ "CACHE" ,
233+ ):
234+ return self .op_stack
235+
236+ if opname .startswith (("LOAD_" , "STORE_" , "DELETE_" , "IMPORT_" )):
237+ return self .op_load_store
238+
239+ if opname .startswith (("CALL" , "RETURN" )) or opname in (
240+ "YIELD_VALUE" ,
241+ "MAKE_FUNCTION" ,
242+ "SET_FUNCTION_ATTRIBUTE" ,
243+ "RESUME" ,
244+ ):
245+ return self .op_call_return
246+
247+ if opname .startswith (("BINARY_" , "UNARY_" )) or opname in (
248+ "COMPARE_OP" ,
249+ "IS_OP" ,
250+ "CONTAINS_OP" ,
251+ "GET_ITER" ,
252+ "GET_YIELD_FROM_ITER" ,
253+ "TO_BOOL" ,
254+ "DELETE_SUBSCR" ,
255+ ):
256+ return self .op_binary_unary
257+
258+ if opname .startswith (("JUMP_" , "POP_JUMP_" , "FOR_ITER" )) or opname in (
259+ "SEND" ,
260+ "GET_AWAITABLE" ,
261+ "GET_AITER" ,
262+ "GET_ANEXT" ,
263+ "END_ASYNC_FOR" ,
264+ "CLEANUP_THROW" ,
265+ ):
266+ return self .op_control_flow
267+
268+ if opname .startswith (
269+ ("BUILD_" , "LIST_" , "DICT_" , "UNPACK_" )
270+ ) or opname in ("SET_ADD" , "MAP_ADD" , "SET_UPDATE" ):
271+ return self .op_build
272+
273+ if opname .startswith (("SETUP_" , "CHECK_" )) or opname in (
274+ "POP_EXCEPT" ,
275+ "RERAISE" ,
276+ "WITH_EXCEPT_START" ,
277+ "RAISE_VARARGS" ,
278+ "POP_BLOCK" ,
279+ ):
280+ return self .op_exceptions
281+
282+ return self .op_other
283+
284+
203285@dataclass (frozen = True , kw_only = True )
204286class LiveProfiler (ThemeSection ):
205287 """Theme section for the live profiling TUI (Tachyon profiler).
@@ -343,89 +425,6 @@ class Unittest(ThemeSection):
343425 fail_info : str = ANSIColors .BOLD_RED
344426 reset : str = ANSIColors .RESET
345427
346-
347- @dataclass (frozen = True , kw_only = True )
348- class Dis (ThemeSection ):
349- label_bg : str = ANSIColors .BACKGROUND_BLUE
350- label_fg : str = ANSIColors .BLACK
351- exception_label : str = ANSIColors .CYAN
352- argument_detail : str = ANSIColors .GREY
353-
354- op_stack : str = ANSIColors .BOLD_YELLOW
355- op_load_store : str = ANSIColors .BOLD_CYAN
356- op_call_return : str = ANSIColors .BOLD_MAGENTA
357- op_binary_unary : str = ANSIColors .BOLD_BLUE
358- op_control_flow : str = ANSIColors .BOLD_GREEN
359- op_build : str = ANSIColors .BOLD_WHITE
360- op_exceptions : str = ANSIColors .BOLD_RED
361- op_other : str = ANSIColors .GREY
362-
363- reset : str = ANSIColors .RESET
364-
365- def color_by_opname (self , opname : str ) -> str :
366- if opname in (
367- "POP_TOP" ,
368- "POP_ITER" ,
369- "END_FOR" ,
370- "END_SEND" ,
371- "COPY" ,
372- "SWAP" ,
373- "PUSH_NULL" ,
374- "PUSH_EXC_INFO" ,
375- "NOP" ,
376- "CACHE" ,
377- ):
378- return self .op_stack
379-
380- if opname .startswith (("LOAD_" , "STORE_" , "DELETE_" , "IMPORT_" )):
381- return self .op_load_store
382-
383- if opname .startswith (("CALL" , "RETURN" )) or opname in (
384- "YIELD_VALUE" ,
385- "MAKE_FUNCTION" ,
386- "SET_FUNCTION_ATTRIBUTE" ,
387- "RESUME" ,
388- ):
389- return self .op_call_return
390-
391- if opname .startswith (("BINARY_" , "UNARY_" )) or opname in (
392- "COMPARE_OP" ,
393- "IS_OP" ,
394- "CONTAINS_OP" ,
395- "GET_ITER" ,
396- "GET_YIELD_FROM_ITER" ,
397- "TO_BOOL" ,
398- "DELETE_SUBSCR" ,
399- ):
400- return self .op_binary_unary
401-
402- if opname .startswith (("JUMP_" , "POP_JUMP_" , "FOR_ITER" )) or opname in (
403- "SEND" ,
404- "GET_AWAITABLE" ,
405- "GET_AITER" ,
406- "GET_ANEXT" ,
407- "END_ASYNC_FOR" ,
408- "CLEANUP_THROW" ,
409- ):
410- return self .op_control_flow
411-
412- if opname .startswith (
413- ("BUILD_" , "LIST_" , "DICT_" , "UNPACK_" )
414- ) or opname in ("SET_ADD" , "MAP_ADD" , "SET_UPDATE" ):
415- return self .op_build
416-
417- if opname .startswith (("SETUP_" , "CHECK_" )) or opname in (
418- "POP_EXCEPT" ,
419- "RERAISE" ,
420- "WITH_EXCEPT_START" ,
421- "RAISE_VARARGS" ,
422- "POP_BLOCK" ,
423- ):
424- return self .op_exceptions
425-
426- return self .op_other
427-
428-
429428@dataclass (frozen = True , kw_only = True )
430429class Theme :
431430 """A suite of themes for all sections of Python.
0 commit comments