File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed
Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change 2222''' , re .VERBOSE )
2323
2424
25- def _colorize_json ( json_str ):
26- colors = {
27- 'string ' : ANSIColors .GREEN ,
28- 'number ' : ANSIColors .YELLOW ,
29- 'boolean ' : ANSIColors .CYAN ,
30- 'null' : ANSIColors . CYAN ,
31- }
25+ _colors = {
26+ 'string' : ANSIColors . GREEN ,
27+ 'number ' : ANSIColors .YELLOW ,
28+ 'boolean ' : ANSIColors .CYAN ,
29+ 'null ' : ANSIColors .CYAN ,
30+ }
31+
3232
33- def replace (match ):
34- for key in colors :
35- if m := match .group (key ):
36- color = colors [key ]
37- return f"{ color } { m } { ANSIColors .RESET } "
38- return match .group ()
33+ def _replace_match_callback (match ):
34+ for key in _colors :
35+ if m := match .group (key ):
36+ color = _colors [key ]
37+ return f"{ color } { m } { ANSIColors .RESET } "
38+ return match .group ()
3939
40- return re .sub (_color_pattern , replace , json_str )
40+
41+ def _colorize_json (json_str ):
42+ return re .sub (_color_pattern , _replace_match_callback , json_str )
4143
4244
4345def main ():
You can’t perform that action at this time.
0 commit comments