o
    /ho                     @   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   C/var/www/html/myenv/lib/python3.10/site-packages/cssutils/helper.py__init__   s   
zDeprecated.__init__c                    s0    fdd} j |_  j|_|j j |S )Nc                     s6   dd l }|jd jdj tdd  | i |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   __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 )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)matchobjr   r   r   removeescape7   s   znormalize.<locals>.removeescape)_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   path2url@   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   	pushtokenE   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   stringK   s   

r8   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``
    r2   r   r   r3   )r4   )r8   r   r   r   stringvalue_   s    r9   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_urir8   r6   r   r   r   uril   s   r;   c                 C   sF   | |  dd d  } | r!| d dv r!| d | d kr!t| S | S )z
    Return actual content without surrounding "url(" and ")"
    and removed surrounding quotes too including contained
    escapes of quotes, e.g.::

         ``url(""")`` => ``"``
    (r   r3   r   z'")findstripr9   )r;   r   r   r   urivaluew   s    r?   )r   r)   r%   reurllib.errorr"   urllib.parseurllib.requestr   compilesubr   r!   r(   r-   r8   r9   Umatchr:   r;   r?   r   r   r   r   <module>   s"    
