U
    8b                     @   sj  d dl mZmZ d dlmZmZ ddlmZ eedddZ	G dd	 d	eZ
G d
d de
ZG dd de
ZG dd deZG dd deZedkrfddlmZ e Zed ed ed ed ed ed ed ed ed ed ed ed ed  ed! ed" ed# ed$ ed% ed& d'S )(    )ABCabstractmethod)ListUnion   )Text)regexesreturnc                  G   s
   d | S )z{Combine a number of regexes in to a single regex.

    Returns:
        str: New regex with all regexes ORed together.
    |)join)r    r   @/tmp/pip-unpacked-wheel-_2d0jb6m/pip/_vendor/rich/highlighter.py_combine_regex   s    r   c                   @   s<   e Zd ZdZeeef edddZeeddddZ	dS )Highlighterz%Abstract base class for highlighters.textr	   c                 C   sD   t |trt|}n"t |tr(| }ntd|| | |S )a	  Highlight a str or Text instance.

        Args:
            text (Union[str, ~Text]): Text to highlight.

        Raises:
            TypeError: If not called with text or str.

        Returns:
            Text: A test instance with highlighting applied.
        z#str or Text instance required, not )
isinstancestrr   copy	TypeError	highlight)selfr   Zhighlight_textr   r   r   __call__   s    




zHighlighter.__call__Nc                 C   s   dS )zoApply highlighting in place to text.

        Args:
            text (~Text): A text object highlight.
        Nr   r   r   r   r   r   r   (   s    zHighlighter.highlight)
__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r      s   r   c                   @   s    e Zd ZdZeddddZdS )NullHighlighterzeA highlighter object that doesn't highlight.

    May be used to disable highlighting entirely.

    Nr   c                 C   s   dS )zNothing to doNr   r   r   r   r   r   8   s    zNullHighlighter.highlight)r   r   r   r   r   r   r   r   r   r   r   1   s   r   c                   @   s>   e Zd ZU dZg Zee ed< dZeed< e	ddddZ
dS )	RegexHighlighterz8Applies highlighting from a list of regular expressions.
highlights 
base_styleNr   c                 C   s$   |j }| jD ]}||| jd qdS )zHighlight :class:`rich.text.Text` using regular expressions.

        Args:
            text (~Text): Text to highlighted.

        )Zstyle_prefixN)highlight_regexr    r"   )r   r   r#   Zre_highlightr   r   r   r   B   s    
zRegexHighlighter.highlight)r   r   r   r   r    r   r   __annotations__r"   r   r   r   r   r   r   r   <   s   
r   c                   @   s:   e Zd ZdZdZdddedddd	d
dddddddgZdS )ReprHighlighterzAHighlights the text typically produced from ``__repr__`` methods.zrepr.zS(?P<tag_start>\<)(?P<tag_name>[\w\-\.\:]*)(?P<tag_contents>[\w\W]*?)(?P<tag_end>\>)z<(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>\"?[\w_]+\"?)?(?P<brace>[\{\[\(\)\]\}])z8(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})z4(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})z(?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})z(?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})z(?P<call>[\w\.]*?)\(zD\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\bz(?P<ellipsis>\.\.\.)E(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[\-\+]?\d+?)?\b|0x[0-9a-fA-F]*)z<(?P<path>\B(\/[\w\.\-\_\+]+)*\/)(?P<filename>[\w\.\-\_\+]*)?zg(?<![\\\w])(?P<str>b?\'\'\'.*?(?<!\\)\'\'\'|b?\'.*?(?<!\\)\'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")zY(?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})zU(?P<url>(file|https|http|ws|wss):\/\/[0-9a-zA-Z\$\-\_\+\!`\(\)\,\.\?\/\;\:\&\=\%\#]*)Nr   r   r   r   r"   r   r    r   r   r   r   r%   O   s(   r%   c                   @   s&   e Zd ZdZdZedddddgZdS )	JSONHighlighterzHighlights JSONzjson.r&   zD\b(?P<bool_true>true)\b|\b(?P<bool_false>false)\b|\b(?P<null>null)\br'   z$(?<![\\\w])(?P<str>b?\".*?(?<!\\)\")z&(?<![\\\w])(?P<key>b?\".*?(?<!\\)\")\:Nr(   r   r   r   r   r)   h   s   r)   __main__)Consolez%[bold green]hello world![/bold green]z''[bold green]hello world![/bold green]'z /fooz/foo/z/foo/barzfoo/bar/bazz /foo/bar/baz?foo=bar+egg&egg=bazz/foo/bar/baz/z/foo/bar/baz/eggz/foo/bar/baz/egg.pyz/foo/bar/baz/egg.py wordz /foo/bar/baz/egg.py wordzfoo /foo/bar/baz/egg.py wordz!foo /foo/bar/ba._++z/egg+.py wordz"https://example.org?foo=bar#headergq=
W2Ag      ?gF!@ܡzE127.0.1.1 bar 192.168.1.4 2001:0db8:85a3:0000:0000:8a2e:0370:7334 fooN)abcr   r   typingr   r   r   r   r   r   r   r   r   r%   r)   r   consoler+   printr   r   r   r   <module>   s@   	!


















