B
    '‹dw  ã               @   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   ú`/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/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é   Ú
z\A úz\D úz\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   z\A r   z\D r   z\C 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 )ú"z\"r   z\\r   z\A r   z\D r   z\C Nr   )r   r   r   r   r   r   G   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   z\"r   z\\ú z\ ú	z\9 r   z\A r   z\D r   z\C ú(z\(ú)z\)Nr   )r   r   r   r   r   r   S   s   z serialize_url.<locals>.<genexpr>)r   )r   r   r   r   Úserialize_urlQ   s    r#   c             C   sˆ   t }d}xz| D ]r}|jdkr"|jn|j}||f|kr>|dƒ n$|dkrb|dkrZ|j d¡sb|dƒ | |¡ |dkr||dƒ |}qW 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Ú	dimensionzunicode-ranger   )r   ÚaÚbr   r   r   ú
<listcomp>{   s   r4   )r,   z
at-keywordÚhashr1   ú#r
   r/   c             C   s   g | ]}d D ]}||f‘qqS ))r
   z-->r   )r   r2   r3   r   r   r   r4   €   s   )r,   z
at-keywordr5   r1   c             C   s   g | ]}d D ]}||f‘qqS ))r,   r-   r.   r   )r   r2   r3   r   r   r   r4   ƒ   s   )r6   r
   r/   ú@c             C   s   g | ]}d D ]}||f‘qqS ))r/   r0   r1   r   )r   r2   r3   r   r   r   r4   †   s   )zunicode-rangeÚ.ú+c             C   s   g | ]}d |f‘qS )r7   r   )r   r3   r   r   r   r4   ‰   s    )r,   r-   r.   zunicode-ranger
   c             C   s   g | ]}d |f‘qS )zunicode-ranger   )r   r3   r   r   r   r4   Š   s    )r,   r-   ú?c             C   s   g | ]}|d f‘qS )ú=r   )r   r2   r   r   r   r4   ‹   s    z$*^~|)r,   z() block)ú|r<   )ú/Ú*N)r	   r   r   r   r#   r   Úsetr'   r   r   r   r   Ú<module>   s   %`