3
3P7                 @   s   d Z ddlmZ ddlmZ dejejejejej	ej
eeeedfddZd	d
 ZdddZeZyddlmZ W n ek
r   dZY nX ejZeZdS )a,  
    tinycss.tokenizer
    -----------------

    Tokenizer for the CSS core syntax:
    http://www.w3.org/TR/CSS21/syndata.html#tokenization

    This is the pure-python implementation. See also speedups.pyx

    :copyright: (c) 2012 by Simon Sapin.
    :license: BSD, see LICENSE for more details.
    )unicode_literals   )
token_dataTNc             C   s  d}d}d}|| }g }x|||k r| | }|dkr@|}|}nFt t|d}x6|| D ]"\}}}|| |}|rX|j }P qXW d}|}||}|| }|o|dksT|}|dkr|jd}d	|kr|
|n|	|}|jd
}||}||}|j }nD|dkr0|dd }d	|kr |
|n|	|}d}n|dkr`|}d	|krR|
|}n|	|}d}n|dkr|||}||}n|dkr|jd}|r|d dkr|dd }||}||}||}nr|dkr|dd }||}||}||}nB|dkr8||kr8d}|dd }||}||}||}n|}|j||||||| |}|||}|r|||7 }||d j  d }q||7 }qW |S )z
    :param css_source:
        CSS as an unicode string
    :param ignore_comments:
        if true (the default) comments will not be included in the
        return value
    :return:
        An iterator of :class:`Token`

    r   r   z:;{}()[]   ZDELIMCOMMENTBAD_COMMENTZ	DIMENSION.   Z
PERCENTAGEN%NUMBERZINTEGERIDENT	ATKEYWORDHASHFUNCTIONURIz"'STRINGZ
BAD_STRING)r   r   )r   r   r   r   r   r   r   )minordgrouplowerappendend)
css_sourceignore_commentsZtokens_dispatchZunicode_unescapeZnewline_unescapeZsimple_unescapeZfind_newlinesTokenlenintfloatlistZ_NoneposlinecolumnZ
source_lentokenschartype_Z	css_valueZ	codepoint_indexZregexpmatchlengthZnext_posZunitvaluenewlines r+   Q/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/tinycss/tokenizer.pytokenize_flat   s    













	
r-   c                s@   ddddd}t | } dg}d| ||tjtjf fdd	   S )	a  
    Match pairs of tokens: () [] {} function()
    (Strings in "" or '' are taken care of by the tokenizer.)

    Opening tokens are replaced by a :class:`ContainerToken`.
    Closing tokens are removed. Unmatched closing tokens are invalid
    but left as-is. All nested structures that are still open at
    the end of the stylesheet are implicitly closed.

    :param tokens:
        a *flat* iterable of tokens, as returned by :func:`tokenize_flat`.
    :return:
        A tree of tokens.

    )]})r   ([{FNc       
   	   3   s   x|D ]}|j }|| krd S |j|}|d kr6|V  qt|| sPtdj|t |}	|d rhd}|dkr||j |j ||j|	|j|j	V  q||j |j ||	|j|j	V  qW d|d< d S )Nz Token looks already grouped: {0}r    r   T)
typeget
isinstanceAssertionErrorformatr   Zas_cssr)   r!   r"   )
Zstop_atr#   pairseofContainerTokenFunctionTokentokenr%   r   content)_regroup_innerr+   r,   r@      s(    

zregroup.<locals>._regroup_inner)iterr   r<   r=   )r#   r:   r;   r+   )r@   r,   regroup   s    rB   c             C   s   t t| |S )z
    :param css_source:
        CSS as an unicode string
    :param ignore_comments:
        if true (the default) comments will not be included in the
        return value
    :return:
        An iterator of :class:`Token`

    )rB   r-   )r   r   r+   r+   r,   tokenize_grouped   s    rC   )speedups)T)__doc__
__future__r   r4   r   ZTOKEN_DISPATCHZUNICODE_UNESCAPEZNEWLINE_UNESCAPEZSIMPLE_UNESCAPEZFIND_NEWLINESr   r   r   r   r   r-   rB   rC   Zpython_tokenize_flatrD   ImportErrorZcython_tokenize_flatr+   r+   r+   r,   <module>   s.   l4

