(json_str, theme)
| 32 | |
| 33 | |
| 34 | def _colorize_json(json_str, theme): |
| 35 | def _replace_match_callback(match): |
| 36 | for group, color in _group_to_theme_color.items(): |
| 37 | if m := match.group(group): |
| 38 | return f"{theme[color]}{m}{theme.reset}" |
| 39 | return match.group() |
| 40 | |
| 41 | return re.sub(_color_pattern, _replace_match_callback, json_str) |
| 42 | |
| 43 | |
| 44 | def main(): |