o
    bb                     @   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d	ed
edefddZeddd	ed
edefddZeddd	ed
edefddZG dd dZG dd dZG dd dZG dd deZdedefddZ	d$deee	e f dedefdd Zd!edef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_namesZconfigurationc                 C   sb   || j v rtd| j|| jtt| |  d S || j	v r(t
| || d S td| j|)Nz'{}.{} {} is {} and cannot be overriddenzno such {} {!r})r	   warningswarnformat__name__
_type_descstrgetattrupperr   setattr
ValueError)clsZdnamevalue r   /home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/build/host-python-setuptools-62.6.0/pkg_resources/_vendor/pyparsing/util.py_set   s   

z__config_flags._setc                 C      |  |dS )NTr   r   namer   r   r   <lambda>$       z__config_flags.<lambda>c                 C   r   )NFr   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 rn n
|| d  dkrd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   Br0   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   r2   c                 C   sB   | dd| }|d| }|dkr||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)   Zlast_crZnext_crr   r   r   lineG   s   (r4   c                   @      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 Nr   _key	cache_getnot_in_cacher   r   getW      
z%_UnboundedCache.__init__.<locals>.getc                    s   | |< d S r8   r   r:   r;   r   cacher   r   set_Z      z&_UnboundedCache.__init__.<locals>.set_c                           d S r8   clearr:   rB   r   r   rH   ]   rE   z'_UnboundedCache.__init__.<locals>.clear)r?   objectr>   sizetypes
MethodTypesetrH   )selfr?   rD   rH   r   )rC   r=   r>   r   __init__R   s   z_UnboundedCache.__init__Nr   r   r    rP   r   r   r   r   r6   Q       r6   c                   @   r5   )
_FifoCachec                    sv   t   | _t   jfdd} fdd} fdd}| _t|| | _t|| | _t|| | _	d S )Nc                    r7   r8   r   r9   r<   r   r   r?   l   r@   z _FifoCache.__init__.<locals>.getc                    s4   | |< t  kr jdd t  ks
d S d S NF)last)r-   popitemrA   )rC   rK   r   r   rD   o   s   z!_FifoCache.__init__.<locals>.set_c                    rF   r8   rG   rI   rB   r   r   rH   t   rE   z"_FifoCache.__init__.<locals>.clear)
rJ   r>   collectionsOrderedDictr?   rK   rL   rM   rN   rH   )rO   rK   r?   rD   rH   r   )rC   r=   r>   rK   r   rP   g   s   z_FifoCache.__init__NrQ   r   r   r   r   rS   f   rR   rS   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 r8   )	_capacity_activerW   rX   _memory)rO   Zcapacityr   r   r   rP      s   zLRUMemo.__init__c                 C   s6   z| j | W S  ty   | j| | j|  Y S w r8   )r[   KeyErrorr\   move_to_endrO   r;   r   r   r   __getitem__   s   zLRUMemo.__getitem__c                 C   s   | j |d  || j|< d S r8   )r\   popr[   rO   r;   r   r   r   r   __setitem__   s   zLRUMemo.__setitem__c                 C   sb   z| j |}W n
 ty   Y d S w t| j| jkr*| jjdd t| j| jks|| j|< d S rT   )r[   ra   r]   r-   r\   rZ   rV   rb   r   r   r   __delitem__   s   zLRUMemo.__delitem__c                 C   s   | j   | j  d S r8   )r[   rH   r\   )rO   r   r   r   rH      s   
zLRUMemo.clearN)	r   r   r    r!   rP   r`   rc   rd   rH   r   r   r   r   rY   }   s    
rY   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 r8   r   r_   r   r   r   rd         zUnboundedMemo.__delitem__N)r   r   r    r!   rd   r   r   r   r   re      s    re   r/   c                 C   s:   dD ]
}|  |t| } q|  dd} |  dd} t| S )Nz\^-[]r,   z\n	z\t)replace_bslashr   )r/   cr   r   r   _escape_regex_range_chars   s
   rk   T	re_escapec           	   	      s  fddd_ t _d_dd  dd }|s| g }d	tt| } t| d
krytj	| dD ]B\}}t
| }}tjtt|g|dd }||kr[| | q5t|t|d krgd	nd}|d || | q5n	 fdd| D }d	|S )Nc                    s4   t | }| j _}|| dkrt j _ jS )Nr+   )ordprevnextcounterr   )rj   Zc_intrn   )is_consecutiver   r   rq      s
   z2_collapse_string_to_ranges.<locals>.is_consecutiver   c                 S   s   | dv rd|  S | S )Nz\^-][\r   rj   r   r   r   escape_re_range_char   s   z8_collapse_string_to_ranges.<locals>.escape_re_range_charc                 S   s   | S r8   r   rt   r   r   r   no_escape_re_range_char   rf   z;_collapse_string_to_ranges.<locals>.no_escape_re_range_char    )r;   r+   )maxlen-z{}{}{}c                    s   g | ]} |qS r   r   ).0rj   )ru   r   r   
<listcomp>   s    z._collapse_string_to_ranges.<locals>.<listcomp>)rn   	itertoolsr1   rp   r   joinsortedrN   r-   groupbyro   rW   dequechainiterra   appendrm   r   )	r/   rl   rv   retr:   charsfirstrU   sepr   )ru   rq   r   _collapse_string_to_ranges   s:   

r   llc                 C   s6   g }| D ]}t |tr|t| q|| q|S r8   )
isinstancelistextend_flattenr   )r   r   ir   r   r   r      s   
r   )T)r
   rL   rW   r}   	functoolsr   typingr   r   r   chrri   r   intr   r0   r2   r4   r6   rS   rY   dictre   rk   boolr   r   r   r   r   r   r   <module>   s8   	'	

.