MCPcopy
hub / github.com/Textualize/rich / ReprHighlighter

Class ReprHighlighter

rich/highlighter.py:80–103  ·  view source on GitHub ↗

Highlights the text typically produced from ``__repr__`` methods.

Source from the content-addressed store, hash-verified

78
79
80class ReprHighlighter(RegexHighlighter):
81 """Highlights the text typically produced from ``__repr__`` methods."""
82
83 base_style = "repr."
84 highlights: ClassVar[Sequence[str]] = [
85 r"(?P<tag_start><)(?P<tag_name>[-\w.:|]*)(?P<tag_contents>[\w\W]*)(?P<tag_end>>)",
86 r'(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>"?[\w_]+"?)?',
87 r"(?P<brace>[][{}()])",
88 _combine_regex(
89 r"(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})",
90 r"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})",
91 r"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})",
92 r"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})",
93 r"(?P<uuid>[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})",
94 r"(?P<call>[\w.]*?)\(",
95 r"\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\b",
96 r"(?P<ellipsis>\.\.\.)",
97 r"(?P<number_complex>(?<!\w)(?:\-?[0-9]+\.?[0-9]*(?:e[-+]?\d+?)?)(?:[-+](?:[0-9]+\.?[0-9]*(?:e[-+]?\d+)?))?j)",
98 r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
99 r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
100 r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
101 r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)",
102 ),
103 ]
104
105
106class JSONHighlighter(RegexHighlighter):

Callers 10

test_highlight_regexFunction · 0.90
table.pyFile · 0.90
align.pyFile · 0.90
__init__Method · 0.85
__rich_console__Method · 0.85
_render_syntax_errorMethod · 0.85
_PlaceholderClass · 0.85
__init__Method · 0.85
__init__Method · 0.85
render_scopeFunction · 0.85

Calls 1

_combine_regexFunction · 0.85

Tested by 1

test_highlight_regexFunction · 0.72