U
    pc+                     @   s   d Z ddlmZmZ ddlZddlZddlmZmZm	Z	m
Z
mZ dZedZedZedZed	d
eedddZG dd deZdeeedef dddZdeeddddZeee
eeef dddZdS )zUtility.    )wraps	lru_cacheN)CallableAnyOptionalTupleList   z(?:\r\n|(?!\r\n)[\n\r])|$AZi   )maxsize)stringreturnc                 C   sN   g }| D ]:}t |}|t|  kr,tkr<n nt|d n| qd|S )zLower.     )ordappendUC_AUC_Zchrjoin)r   Z
new_stringco r   2/tmp/pip-unpacked-wheel-ytx3zl4o/soupsieve/util.pylower   s
    0r   c                       s6   e Zd ZdZdeee ee dd fddZ  ZS )SelectorSyntaxErrorzSyntax error in a CSS selector.N)msgpatternindexr   c                    sZ   d| _ d| _d| _|dk	rJ|dk	rJt||\| _| _ | _d|| j | j}t | dS )zInitialize.Nz{}
  line {}:
{})linecolcontextget_pattern_contextformatsuper__init__)selfr   r   r   	__class__r   r   r&      s    zSelectorSyntaxError.__init__)NN)	__name__
__module____qualname____doc__strr   intr&   __classcell__r   r   r(   r   r      s   r      .)message
stacklevelr   c                    s*   t dtf t dtf d fdd}|S )z
    Raise a `DeprecationWarning` when wrapped function/method is called.

    Usage:

        @deprecated("This method will be removed in version X; use Y instead.")
        def some_method()"
            pass
    .)funcr   c                    s&   t  tttd fdd}|S )N)argskwargsr   c                     s(   t jd j d td  | |S )N'z' is deprecated. categoryr3   )warningswarnr*   DeprecationWarning)r5   r6   )r4   r2   r3   r   r   _deprecated_func8   s    z6deprecated.<locals>._wrapper.<locals>._deprecated_func)r   r   )r4   r=   r2   r3   )r4   r   _wrapper7   s    zdeprecated.<locals>._wrapper)r   r   )r2   r3   r?   r   r>   r   
deprecated,   s    &
r@   c                 C   s   t j| t|d dS )zWarn deprecated.r8   N)r:   r;   r<   r>   r   r   r   warn_deprecatedD   s
    rA   )r   r   r   c                 C   s,  d}d}d}g }d}d}t | D ]}| ||d }	t|dsdt|sdd}
d}|| d }nR||  kr~|dk rn n,d}
||dkrdndd }|| d }nd}
d}t|r|d	 |d
|
|	 |dk	r|d	 |d||  d  |}|d7 }|d}q"d|||fS )zGet the pattern context.r   r	   Nr   z-->    z    
z{}{} ^)	RE_PATTERN_LINE_SPLITfinditerstartlengroupendr   r$   r   )r   r   lastcurrent_liner!   textr    offsetmZlinetextindentr   r   r   r#   N   s8    


r#   )r1   )r1   )r-   	functoolsr   r   r:   retypingr   r   r   r   r   DEBUGcompilerG   r   r   r   r.   r   	Exceptionr   r/   r@   rA   r#   r   r   r   r   <module>   s   


