B
    5dm                 @   s   d Z ddlZddlZddlZddlZddlZddlZG dd dZe	dj
Zdd Zdd	 Zd
d Zdd Zdd Ze	dejjZdd Zdd ZdS )zcssutils helper TEST
    Nc               @   s    e Zd ZdZdd Zdd ZdS )
Deprecateda.  This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.

    It accepts a single paramter ``msg`` which is shown with the warning.
    It should contain information which function or method to use instead.
    c             C   s
   || _ d S )N)msg)selfr    r   3/tmp/pip-unpacked-wheel-v2oh4n0p/cssutils/helper.py__init__   s    zDeprecated.__init__c                s0    fdd} j |_  j|_|j j |S )Nc                 s2   dd l }|jd jdj tdd  | |S )Nr   zCall to deprecated method z.    )category
stacklevel)warningswarn__name__r   DeprecationWarning)argskwargsr   )funcr   r   r   newFunc   s    z$Deprecated.__call__.<locals>.newFunc)r   __doc____dict__update)r   r   r   r   )r   r   r   __call__   s
    
zDeprecated.__call__N)r   
__module____qualname__r   r   r   r   r   r   r   r      s   r   z(\\[^0-9a-fA-F])c             C   s&   | rdd }t || } |  S | S dS )z
    normalizes x, namely:

    - remove any \ before non unicode sequences (0-9a-zA-Z) so for
      x==r"c\olor\" return "color" (unicode escape sequences should have
      been resolved by the tokenizer already)
    - lowercase
    c             S   s   |  ddd  S )Nr      )group)Zmatchobjr   r   r   removeescape8   s    znormalize.<locals>.removeescapeN)_simpleescapeslower)xr   r   r   r   	normalize-   s
    	
r   c             C   s   dt jtj|  S )zReturn file URL of `path`zfile:)urllibrequestpathname2urlospathabspath)r$   r   r   r   path2urlA   s    r&   c             C   s   t | g|S )zQReturn new generator starting with token followed by all tokens in
    ``tokens``)	itertoolschain)tokentokensr   r   r   	pushtokenF   s    r+   c             C   sF   |  dd dd dd dd} | d	r>| d
d d } d|  S )zV
    Serialize value with quotes e.g.::

        ``a 'string`` => ``'a 'string'``
    
z\a z\d z\c "z\"\Nz\\z"%s")replaceendswith)valuer   r   r   stringL   s    
r5   c             C   s    |  d| d  | d dd S )z
    Retrieve actual value of string without quotes. Escaped
    quotes inside the value are resolved, e.g.::

        ``'a 'string'`` => ``a 'string``
    r0   r   r   r1   )r2   )r5   r   r   r   stringvalue`   s    r6   z.*?[\(\)\s\;,'"]c             C   s   t | rt| } d|  S )zm
    Serialize value by adding ``url()`` and with quotes if needed e.g.::

        ``"`` => ``url(""")``
    zurl(%s))_match_forbidden_in_urir5   )r4   r   r   r   urim   s    r8   c             C   sJ   | |  dd d  } | rB| d dkrB| d | d krBt| S | S dS )z
    Return actual content without surrounding "url(" and ")"
    and removed surrounding quotes too including contained
    escapes of quotes, e.g.::

         ``url(""")`` => ``"``
    (r   r1   r   z'"N)findstripr6   )r8   r   r   r   urivaluex   s     r<   )r   r#   rer'   urllib.requestr    urllib.errorurllib.parser   compilesubr   r   r&   r+   r5   r6   Umatchr7   r8   r<   r   r   r   r   <module>   s    
