3
d+                 @   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j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   sR   g }xB| D ]:}t |}|jt|  ko,tkn  r>t|d n| q
W dj|S )zLower.     )ordappendUC_AUC_Zchrjoin)r   Z
new_stringco r   3/tmp/pip-build-8z3xcdsh/soupsieve/soupsieve/util.pylower   s
    
2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 | j}t j| 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. )categoryr2   )warningswarnr)   DeprecationWarning)r4   r5   )r3   r1   r2   r   r   _deprecated_func8   s
    z6deprecated.<locals>._wrapper.<locals>._deprecated_func)r   r   )r3   r;   )r1   r2   )r3   r   _wrapper7   s    zdeprecated.<locals>._wrapper)r   r   )r1   r2   r<   r   )r1   r2   r   
deprecated,   s    &
r=   c             C   s   t j| t|d dS )zWarn deprecated.)r7   r2   N)r8   r9   r:   )r1   r2   r   r   r   warn_deprecatedD   s    r>   )r   r   r   c             C   s8  d}d}d}g }d}d}xt j| D  ]}| ||jd }	t|jd rnt| rnd}
d}|| d }nR||  ko|jdk n  rd}
||jdkrdndd }|| d }nd}
d}t|r|jd |jd	j|
|	 |dk	r|jd |jd
||  d  |}|d7 }|jd}q&W dj|||fS )zGet the pattern context.r   r	   Nr   z-->    z    
z{}{} ^rC   )	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#   )r0   )r0   )r,   	functoolsr   r   r8   retypingr   r   r   r   r   DEBUGcompilerD   r   r   r   r-   r   	Exceptionr   r.   r=   r>   r#   r   r   r   r   <module>   s   


