B
    od                 @   s(  d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	 e
dZG dd dZeddeeed	d
dZeddeeed	ddZeddeeed	ddZG dd dZG dd dZG dd dZG dd deZeedddZd"eee	e f eedddZeedd d!ZdS )#    N)	lru_cache)ListUnionIterable\   c               @   sZ   e Zd ZU dZg Zee ed< g Zee ed< dZ	e
dd Ze
dd Ze
d	d Zd
S )__config_flagsz=Internal class for defining compatibility and debugging flags
_all_names_fixed_namesconfigurationc             C   sd   || j kr6td| j|| jtt| |  d S || j	krNt
| || ntd| j|d S )Nz'{}.{} {} is {} and cannot be overriddenzno such {} {!r})r	   warningswarnformat__name__
_type_descstrgetattrupperr   setattr
ValueError)clsdnamevalue r   L/var/www/html/venv/lib/python3.7/site-packages/pip/_vendor/pyparsing/util.py_set   s    

z__config_flags._setc             C   s   |  |dS )NT)r   )r   namer   r   r   <lambda>$       z__config_flags.<lambda>c             C   s   |  |dS )NF)r   )r   r   r   r   r   r   %   r   N)r   
__module____qualname____doc__r   r   r   __annotations__r	   r   classmethodr   enabledisabler   r   r   r   r      s   
r      )maxsize)locstrgreturnc             C   sF   |}d|   k rt |k r4n n|| d  dkr4dS | |dd|  S )a  
    Returns current column within a string, counting newlines as line separators.
    The first column is number 1.

    Note: the default parsing behavior is to expand tabs in the input string
    before starting the parsing process.  See
    :class:`ParserElement.parseString` for more
    information on parsing strings containing ``<TAB>`` s, and suggested
    methods to maintain a consistent view of the parsed string, the parse
    location, and line and column positions within the parsed string.
    r      
)lenrfind)r'   r(   sr   r   r   col(   s    r/   c             C   s   | dd| d S )a  Returns current line number within a string, counting newlines as line separators.
    The first line is number 1.

    Note - the default parsing behavior is to expand tabs in the input string
    before starting the parsing process.  See :class:`ParserElement.parseString`
    for more information on parsing strings containing ``<TAB>`` s, and
    suggested methods to maintain a consistent view of the parsed string, the
    parse location, and line and column positions within the parsed string.
    r+   r   r*   )count)r'   r(   r   r   r   lineno9   s    r1   c             C   sB   | dd| }|d| }|dkr2||d | S ||d d S )zh
    Returns the line of text containing loc within a string, counting newlines as line separators.
    r+   r   r*   N)r-   find)r'   r(   last_crnext_crr   r   r   lineG   s    r5   c               @   s   e Zd Zdd ZdS )_UnboundedCachec                sp   i   j t  | _fdd} fdd} fdd}d | _t|| | _ t|| | _t|| | _d S )Nc                s
    |S )Nr   )_key)	cache_getnot_in_cacher   r   getW   s    z%_UnboundedCache.__init__.<locals>.getc                s   | |< d S )Nr   )r7   r8   r   )cacher   r   set_Z   s    z&_UnboundedCache.__init__.<locals>.set_c                s       d S )N)clear)r7   )r<   r   r   r>   ]   s    z'_UnboundedCache.__init__.<locals>.clear)r;   objectr:   sizetypes
MethodTypesetr>   )selfr;   r=   r>   r   )r<   r9   r:   r   __init__R   s    z_UnboundedCache.__init__N)r   r   r   rE   r   r   r   r   r6   Q   s   r6   c               @   s   e Zd Zdd ZdS )
_FifoCachec                sv   t   | _t   jfdd} fdd} fdd}| _t|| | _t|| | _t|| | _	d S )Nc                s
    |S )Nr   )r7   r8   )r9   r:   r   r   r;   l   s    z _FifoCache.__init__.<locals>.getc                s*   | |< xt  kr$ jdd q
W d S )NF)last)r,   popitem)r7   r8   r   )r<   r@   r   r   r=   o   s    z!_FifoCache.__init__.<locals>.set_c                s       d S )N)r>   )r7   )r<   r   r   r>   t   s    z"_FifoCache.__init__.<locals>.clear)
r?   r:   collectionsOrderedDictr;   r@   rA   rB   rC   r>   )rD   r@   r;   r=   r>   r   )r<   r9   r:   r@   r   rE   g   s    z_FifoCache.__init__N)r   r   r   rE   r   r   r   r   rF   f   s   rF   c               @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )LRUMemoz
    A memoizing mapping that retains `capacity` deleted items

    The memo tracks retained items by their access order; once `capacity` items
    are retained, the least recently used item is discarded.
    c             C   s   || _ i | _t | _d S )N)	_capacity_activerI   rJ   _memory)rD   capacityr   r   r   rE      s    zLRUMemo.__init__c             C   s6   y
| j | S  tk
r0   | j| | j| S X d S )N)rM   KeyErrorrN   move_to_end)rD   r8   r   r   r   __getitem__   s
    
zLRUMemo.__getitem__c             C   s   | j |d  || j|< d S )N)rN   poprM   )rD   r8   r   r   r   r   __setitem__   s    zLRUMemo.__setitem__c             C   sX   y| j |}W n tk
r$   Y n0X x"t| j| jkrH| jjdd q(W || j|< d S )NF)rG   )rM   rS   rP   r,   rN   rL   rH   )rD   r8   r   r   r   r   __delitem__   s    zLRUMemo.__delitem__c             C   s   | j   | j  d S )N)rM   r>   rN   )rD   r   r   r   r>      s    
zLRUMemo.clearN)	r   r   r   r    rE   rR   rT   rU   r>   r   r   r   r   rK   }   s   
rK   c               @   s   e Zd ZdZdd ZdS )UnboundedMemoz<
    A memoizing mapping that retains all deleted items
    c             C   s   d S )Nr   )rD   r8   r   r   r   rU      s    zUnboundedMemo.__delitem__N)r   r   r   r    rU   r   r   r   r   rV      s   rV   )r.   r)   c             C   s>   xdD ]}|  |t| } qW |  dd} |  dd} t| S )Nz\^-[]r+   z\n	z\t)replace_bslashr   )r.   cr   r   r   _escape_regex_range_chars   s
    
r[   T)r.   	re_escaper)   c       	   	      s  fddd_ t _d_dd  dd }|s:| g }d	tt| } t| d
krxtj	| dD ]\}}t
| }}tjtt|g|dd }||kr| | qlt|t|d krd	nd}|d || | qlW n fdd| D }d	|S )Nc                s4   t | }| j  _}|| dkr.t j _ jS )Nr*   )ordprevnextcounterr   )rZ   c_intr^   )is_consecutiver   r   rb      s
    z2_collapse_string_to_ranges.<locals>.is_consecutiver   c             S   s   | dkrd|  S | S )Nz\^-][\r   )rZ   r   r   r   escape_re_range_char   s    z8_collapse_string_to_ranges.<locals>.escape_re_range_charc             S   s   | S )Nr   )rZ   r   r   r   no_escape_re_range_char   s    z;_collapse_string_to_ranges.<locals>.no_escape_re_range_char    )r8   r*   )maxlen-z{}{}{}c                s   g | ]} |qS r   r   ).0rZ   )re   r   r   
<listcomp>   s    z._collapse_string_to_ranges.<locals>.<listcomp>)r^   	itertoolsr0   r`   r   joinsortedrC   r,   groupbyr_   rI   dequechainiterrS   appendr]   r   )	r.   r\   rf   retr7   charsfirstrG   sepr   )re   rb   r   _collapse_string_to_ranges   s.    
ry   )llr)   c             C   s:   g }x0| D ](}t |tr(|t| q
|| q
W |S )N)
isinstancelistextend_flattenrt   )rz   ru   ir   r   r   r~      s    

r~   )T)r   rA   rI   rm   	functoolsr   typingr   r   r   chrrY   r   intr   r/   r1   r5   r6   rF   rK   dictrV   r[   boolry   r|   r~   r   r   r   r   <module>   s*   	'	
,