U
    nufw  ã                   @   s¤   d d„ Z dd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zedd„ dD ƒdd„ dD ƒ dd„ dD ƒ dd„ dD ƒ dd„ dD ƒ dd„ dD ƒ dd„ dD ƒ dddg ƒZdS )c                 C   s   g }t | |jƒ d |¡S )aã  Serialize nodes to CSS syntax.

    This should be used for :term:`component values`
    instead of just :meth:`tinycss2.ast.Node.serialize` on each node
    as it takes care of corner cases such as ``;`` between declarations,
    and consecutive identifiers
    that would otherwise parse back as the same token.

    :type nodes: :term:`iterable`
    :param nodes: An iterable of :class:`tinycss2.ast.Node` objects.
    :returns: A :obj:`string <str>` representing the nodes.

    Ú )Ú_serialize_toÚappendÚjoin)ÚnodesÚchunks© r   ú7/tmp/pip-unpacked-wheel-29zdolzj/tinycss2/serializer.pyÚ	serialize   s    r	   c                 C   sÎ   | dkrdS | dd… dkr0dt | dd… ƒ S | d dkrNd}| dd… } nd}| d }||d	kspt|ƒd
krt|n>|dkr€dn2|dkrŒdn&|dkr˜dn|dkr¬dt|ƒ nd| 7 }|t | dd… ƒ7 }|S )aX  Serialize any string as a CSS identifier

    :type value: :obj:`str`
    :param value: A string representing a CSS value.
    :returns:
        A :obj:`string <str>` that would parse as an
        :class:`tinycss2.ast.IdentToken` whose
        :attr:`tinycss2.ast.IdentToken.value` attribute equals the passed
        ``value`` argument.

    ú-z\-Né   z--é    é   r   Z5abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZé   Ú
ú\A úú\D úú\C Ú
0123456789z\%X ú\)Úserialize_nameÚord)ÚvalueÚresultÚcr   r   r   Úserialize_identifier   s*    
ÿù	r   c                 C   s   d  dd„ | D ƒ¡S )Nr   c                 s   sR   | ]J}|d kst |ƒdkr|n*|dkr*dn|dkr6dn|dkrBdnd| V  qd	S )
z@abcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZr   r   r   r   r   r   r   r   N)r   ©Ú.0r   r   r   r   Ú	<genexpr>:   s   ú
ÿz!serialize_name.<locals>.<genexpr>©r   ©r   r   r   r   r   9   s    
ùr   c                 C   s   d  dd„ | D ƒ¡S )Nr   c                 s   sN   | ]F}|d krdn2|dkrdn&|dkr*dn|dkr6dn|dkrBd	n|V  qd
S )ú"ú\"r   ú\\r   r   r   r   r   r   Nr   r   r   r   r   r   F   s   úz)serialize_string_value.<locals>.<genexpr>r    r!   r   r   r   Úserialize_string_valueE   s    
ùr%   c                 C   s   d  dd„ | D ƒ¡S )Nr   c                 s   sŠ   | ]‚}|d krdnn|dkrdnb|dkr*dnV|dkr6dnJ|dkrBd	n>|d
krNdn2|dkrZdn&|dkrfdn|dkrrdn|dkr~dn|V  qdS )ú'z\'r"   r#   r   r$   ú z\ ú	z\9 r   r   r   r   r   r   ú(z\(ú)z\)Nr   r   r   r   r   r   R   s   õz serialize_url.<locals>.<genexpr>r    r!   r   r   r   Úserialize_urlQ   s    
ôr+   c                 C   s„   t }d}| D ]r}|jdkr |jn|j}||f|kr<|dƒ n$|dkr`|dkrX|j d¡s`|dƒ | |¡ |dkrz|dƒ |}qdS )	z€Serialize an iterable of nodes to CSS syntax.

    White chunks as a string by calling the provided :obj:`write` callback.

    NÚliteralz/**/r   Ú
whitespacer   Zdeclarationú;)Ú	BAD_PAIRSÚtyper   Ú
startswithr   )r   ÚwriteZ	bad_pairsZprevious_typeÚnodeZserialization_typer   r   r   r   c   s$    ÿ
ÿ
þ
r   c                 C   s   g | ]}d D ]}||f‘qqS ))ÚidentÚfunctionÚurlÚnumberÚ
percentageÚ	dimensionúunicode-ranger   ©r   ÚaÚbr   r   r   Ú
<listcomp>{   s    ýr>   )r4   ú
at-keywordÚhashr9   ú#r
   r7   c                 C   s   g | ]}d D ]}||f‘qqS ))r
   z-->r   r;   r   r   r   r>   €   s    þ)r4   r?   r@   r9   c                 C   s   g | ]}d D ]}||f‘qqS ))r4   r5   r6   r   r;   r   r   r   r>   ƒ   s    þ)rA   r
   r7   ú@c                 C   s   g | ]}d D ]}||f‘qqS ))r7   r8   r9   r   r;   r   r   r   r>   †   s    þ)r:   Ú.ú+c                 C   s   g | ]}d |f‘qS )rB   r   ©r   r=   r   r   r   r>   ‰   s     )r4   r5   r6   r:   r
   c                 C   s   g | ]}d |f‘qS )r:   r   rE   r   r   r   r>   Š   s     )r4   r5   ú?c                 C   s   g | ]}|d f‘qS )ú=r   )r   r<   r   r   r   r>   ‹   s     z$*^~|)r4   z() block)ú|rH   )ú/Ú*N)r	   r   r   r%   r+   r   Úsetr/   r   r   r   r   Ú<module>   s<   %ÿÿûÿøÿõòñðïÿ