3
?W                 @   s  d Z ddlmZmZ ddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZ dd
lmZmZ ddlmZmZ ddlmZmZmZmZ ddlmZ eej eddddgB Z!dbdcdddedZ"eddZ#eddZ$eddZ%e#e#e$e%e%dZ&i Z'i Z(e Z)e Z*dZ+G dd de,Z-dfddZ.dd  Z/d!d" Z0d#d$ Z1d%d& Z2d'd( Z3dgd)d*Z4ddej5 ej5d+ ej5d, d-Z6d.d/ Z7ddej d0  dej d1  d2Z8d3d4 Z9d5d6 Z:e. e3e1d7d8 Z;e.d9e.d:e.d;e.d<e.d=e.d>e2d?d@ Z<e. e2dAdB Z=e. e1dCdD Z>e. e1dEdF Z?e.dGe2dHdG Z@e.dIddJe3e2dKdL ZAdhdidjdOej5d fdkdOej5fdldOej5dS d fdmdndodpdqdrdsdtdudvdwdxdydzd{d|iZBdYdZ ZCd[d\ ZDd]d^ ZEe.d_ddJe2d`da ZFG dbdc dceGZHe.ddddedf ZIe. e3dgdh ZJdidj ZKe. e3dkdl ZLe. e3dmdn ZMe.doe.dpe3e1dqdr ZNe. dsdt ZOe.due.dve.dwe.dxdydz ZPe.d{e.d|e.d}e.d~e.de1dd ZQe.de1dd ZRe.de.de.de.de.de.de2dd ZSe. e2dd ZTe. e1dd ZUe. e1dd ZVe. e1dd ZWe. e1dd ZXe. e2dd ZYe.ddJdd ZZdd Z[dd Z\e. dd Z]e. dd Z^dd Z_e.dNe.dPe.dRe.dQe.de.de.de.de2dd Z`e.de.de2dd Zae. e2dd Zbe. e1dd Zce. e1dd Zde. e1dd Zee.de1dd Zfe. e3dd Zge. e2dd Zhe. e1dd Zie. e1dd Zje. e1ddÄ Zke. e2ddń Zle. e2ddǄ Zme.dȃe.dɃe2dd˄ Zne. e2dd̈́ Zoe. e1ddτ Zpe. e1ddф Zqe.d҃e.dӃe.dԃe.dՃe.dփe.d׃e2ddل Zre.dڃe.dۃe2dd݄ Zse. e2dd߄ Zte. e2dd Zue.de.de2dd Zve. e2dd Zwe. e1dd Zxe.de.de1dd Zye. e1dd Zze. e1dd Z{e. dd Z|e. e1dd Z}e. e1dd Z~e. dd Ze. e2dd Ze. e1dd Ze. e2dd Ze. e1d d Ze. e1dd Ze. e1dd Ze.ddde1dd Ze.ddddd	 Ze.dd
e2dd Ze.ddde2dd Ze. e2dd Ze.dd
e2dd Ze.dd
e2dd Ze.dd
e2dd Ze.dd
dd Ze.dd
e2dd Ze.dd
dd Ze.dd
e2dd Ze.dd
e3d d! Zd"d# Ze.dddd$d% Zd&d' Zd(d) Zed*ed+ed,ed-ed.d/d0 Zed1d2d3 Zd4d5 Zed6ed7d8d9ddJd:d; Zed<d=d> Zed?ed@edAedBedCedDedEdFdGdHdI ZedJdKdL ZedMedNdOdPdQ ZedRedGdSdTdUdVdWdXdYdZ Zed[d\d] Zd}d^d_Zd`da ZdS (~  a9  
    weasyprint.css.validation
    -------------------------

    Expand shorthands and validate property values.
    See http://www.w3.org/TR/CSS21/propidx.html and various CSS3 modules.

    :copyright: Copyright 2011-2014 Simon Sapin and contributors, see AUTHORS.
    :license: BSD, see LICENSE for details.

    )divisionunicode_literalsN)parse_color)split_on_commaremove_whitespace   )LOGGER)counters)urljoinunquote)url_is_absolute
iri_to_uri)LinearGradientRadialGradient   )INITIAL_VALUESKNOWN_PROPERTIESNOT_PRINT_MEDIA	Dimension)computed_valuesexZemchremTF)z
open-quotezclose-quotezno-open-quotezno-close-quote%2   d   )topleftcenterbottomrightz-weasy-c               @   s   e Zd ZdZdS )InvalidValuesz7Invalid or unsupported values for a known CSS property.N)__name__
__module____qualname____doc__ r&   r&   Y/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/weasyprint/css/validation.pyr!   J   s   r!   c                s$    o st  fdd}|S )u  Decorator adding a function to the ``VALIDATORS``.

    The name of the property covered by the decorated function is set to
    ``property_name`` if given, or is inferred from the function name
    (replacing underscores by hyphens).

    :param prefixed:
        Vendor-specific (non-standard) and experimental properties are
        prefixed: stylesheets need to use eg. ``-weasy-bookmark-level: 2``
        instead of ``bookmark-level: 2``.
        See http://wiki.csswg.org/spec/vendor-prefixes
    :param unprefixed:
        Mark properties that used to be prefixed. When used with the prefix,
        they will be ignored be give a specific warning.
    :param wants_base_url:
        The function takes the stylesheet’s base URL as an additional
        parameter.

    c                sj   dkr| j jdd}n}|tks,t||tks<t|| _| t|<  rXtj| rftj| | S )z'Add ``function`` to the ``VALIDATORS``.N_-)	r"   replacer   AssertionError
VALIDATORSwants_base_urlPREFIXEDadd
UNPREFIXED)functionname)prefixedproperty_name
unprefixedr-   r&   r'   	decoratorg   s    

zvalidator.<locals>.decorator)r+   )r4   r3   r5   r-   r6   r&   )r3   r4   r5   r-   r'   	validatorP   s    r7   c             C   s   | j dkr| jj S dS )zQIf ``value`` is a keyword, return its name.

    Otherwise return ``None``.

    IDENTN)typevaluelower)tokenr&   r&   r'   get_keywordz   s    
r=   c             C   s,   t | dkr(| d }|jdkr(|jj S dS )zeIf ``values`` is a 1-element list of keywords, return its name.

    Otherwise return ``None``.

    r   r   r8   N)lenr9   r:   r;   )tokensr<   r&   r&   r'   get_single_keyword   s    
r@   c                s   t j  fdd}|S )z;Decorator for validators that only accept a single keyword.c                s   t | } |r|S dS )z6Wrap a validator to call get_single_keyword on tokens.N)r@   )r?   keyword)r1   r&   r'   keyword_validator   s    z)single_keyword.<locals>.keyword_validator)	functoolswraps)r1   rB   r&   )r1   r'   single_keyword   s    rE   c                s    t j  fdd} |_|S )z9Decorator for validators that only accept a single token.c                s"   t | dkr | d f| S dS )z*Validate a property whose token is single.r   r   N)r>   )r?   args)r1   r&   r'   single_token_validator   s    z,single_token.<locals>.single_token_validator)rC   rD   __func__)r1   rG   r&   )r1   r'   single_token   s    rI   c                s    t j  fdd} |_|S )z<Decorator for validators that accept a comma separated list.c                sB   g }x8t | D ],} t|f| }|d kr0d S |j| qW |S )N)r   r   append)r?   rF   resultspartresult)r1   r&   r'   wrapper   s    z%comma_separated_list.<locals>.wrapper)rC   rD   single_value)r1   rN   r&   )r1   r'   comma_separated_list   s    	rP   c             C   sL   | j tks,|r| j dks,| jdkrH| jdkrH|s:| jdkrHt| j| j S d S )Nr   INTEGERNUMBERr   )rQ   rR   )unitLENGTH_UNITSr9   r:   r   )r<   negative
percentager&   r&   r'   
get_length   s
    
rW         )ZradZturndegZgradc             C   s"   t j| j}|dk	r| j| S dS )z9Return the value in radians of an <angle> token, or None.N)ANGLE_TO_RADIANSgetrS   r:   )r<   factorr&   r&   r'   	get_angle   s    r^   incm)ZdppxZdpiZdpcmc             C   s"   t j| j}|dk	r| j| S dS )z:Return the value in dppx of a <resolution> token, or None.N)RESOLUTION_TO_DPPXr\   rS   r:   )r<   r]   r&   r&   r'   get_resolution   s    rb   c             C   s2   t |rt|S | r"tt| |S td| d S )Nz-Relative URI reference without a base URI: %r)r   r   r
   r!   )base_urlurlr&   r&   r'   safe_urljoin   s    re   c             C   s   | dkS )z.``background-attachment`` property validation.scrollfixedlocal)rf   rg   rh   r&   )rA   r&   r&   r'   background_attachment   s    ri   zbackground-colorzborder-top-colorzborder-right-colorzborder-bottom-colorzborder-left-colorzcolumn-rule-colorc             C   s   t | S )N)r   )r<   r&   r&   r'   other_colors   s    rj   c             C   s   t | dkrdS t| S d S )NinvertcurrentColor)r=   r   )r<   r&   r&   r'   outline_color   s    rm   c             C   s   | dkS )Nseparatecollapse)rn   ro   r&   )rA   r&   r&   r'   border_collapse  s    rp   c             C   s   | dkS )z$``empty-cells`` property validation.showhide)rq   rr   r&   )rA   r&   r&   r'   empty_cells	  s    rs   colorc             C   s   t | }|dkrdS |S dS )z0``*-color`` and ``color`` properties validation.rl   inheritN)r   )r<   rM   r&   r&   r'   rt     s    zbackground-image)r-   c       
      C   s   | j dkrt| g|S tdd | jD }| jj }|dkrlt|\}}|rdtdd |D |d|kfS nd|dkrt|}|d k	r|\}}}	}nd}d}dt	dt	f}	|}|rd	t
dd |D |||	d|kfS d S )NFUNCTIONc             s   s   | ]}|j d kr|V  qdS )SN)r9   ).0tr&   r&   r'   	<genexpr>!  s    z#background_image.<locals>.<genexpr>linear-gradientrepeating-linear-gradientc             S   s   g | ]}t |qS r&   )parse_color_stop)rx   stopr&   r&   r'   
<listcomp>'  s    z$background_image.<locals>.<listcomp>Z	repeatingradial-gradientrepeating-radial-gradientellipserA   farthest-cornerr   r   c             S   s   g | ]}t |qS r&   )r}   )rx   r~   r&   r&   r'   r   4  s    )r{   r|   )r   r   )rA   r   )r9   	image_urlr   contentfunction_namer;    parse_linear_gradient_parametersr    parse_radial_gradient_parametersFIFTY_PERCENTr   )
r<   rc   	argumentsr2   	directionZcolor_stopsrM   shapesizepositionr&   r&   r'   background_image  s,    

r   tor   angler    r   r      cornertop_left	top_rightbottom_leftbottom_rightc             C   sx   | d }t |dkr>t|d }|d k	rjd|f| dd  fS n,tjttt|}|d k	rj|| dd  fS dtjf| fS )Nr   r   r   )	r>   r^   DIRECTION_KEYWORDSr\   tuplemapr=   mathpi)r   Z	first_argr   rM   r&   r&   r'   r   J  s    r   c       
      C   sf  d }d }d }d }| d d d d } x|r|j  }t|}|dkrhtj|d d d }|d krdd S P q&|dkr~|d kr~|}q&|dkr|d krd
|f}q&|r|d krt|dd}t|d dd}	d ||	fkrd||	ff}d}|j   |d krt|}|d k	rd||ff}d}|d kr&d S q&W ||fdkr2d S |p@|p@d|pHd|pXdtdtf| dd  fS )Nr   r   Zatcircler   closest-cornerfarthest-cornerclosest-sidefarthest-siderA   T)rV   explicitr   r   r   )r   r   )r   r   r   r   r   r   r   r   r   )r   r   )rA   r   )popr=   background_positionrO   rW   r   )
r   r   r   r   Z
size_shapestackr<   rA   length_1length_2r&   r&   r'   r   W  sL    



r   c             C   st   t | dkr*t| d }|d k	rl|d fS nBt | dkrlt| d }t| d ddd}|d k	rl|d k	rl||fS td S )Nr   r   r   T)rU   rV   )r>   r   rW   r!   )r?   rt   r   r&   r&   r'   r}     s    
r}   zlist-style-imagec             C   s.   t | dkrdS | jdkr*dt|| jfS dS )z"``*-image`` properties validation.noneNURIrd   )r   N)r=   r9   re   r:   )r<   rc   r&   r&   r'   r     s    
r   c               @   s   e Zd ZdZdZdZdS )CenterKeywordFakeTokenr8   r   N)r"   r#   r$   r9   r:   rS   r&   r&   r&   r'   r     s   r   )r5   c             C   s   t | S )N)simple_2d_position)r?   r&   r&   r'   transform_origin  s    r   c             C   s  t | }|dk	r$|\}}d|d|fS t| dkrt| d }t| d }t| d dd	}t| d
 dd	}|r|r|dkr|dkr||||fS |dkr|dkr||||fS t| d
krt| d dd	}|dk	rt| d }	t| d }
n(t| d dd	}t| d }
t| d }	|dk	r|
dkrR|	dkr:dt|	|fS |	dkr|	|dtfS n@|	dkrr|
dkrr|	||
tfS |	dkr|
dkr|
t|	|fS dS )z|``background-position`` property validation.

    See http://dev.w3.org/csswg/css3-background/#the-background-position

    Nr   r      r   r   r   T)rV   r   r    r   r   )r   r    )r   r   )r   r    )r   r   )r   r   )r   r    )r   r    )r   r   )r   r   )r   r    )r   r>   r=   rW   r   ZERO_PERCENT)r?   rM   Zpos_xZpos_y	keyword_1	keyword_2r   r   lengthrA   Zother_keywordr&   r&   r'   r     sH    







r   c             C   s   t | dkr| d tg} nt | dkr*dS | \}}t|dd}t|dd}|rZ|rZ||fS tt| \}}|r|dkr|t| fS |r|dkrt| |fS |dkr|dkrt| t| fS |dko|dk rt| t| fS dS )z:Common syntax of background-position and transform-origin.r   r   r   NT)rV   r   r   r   r   r    )r   r   r   )r   r   r    )r   r   r    )r   r   r   )r   r   r   )r   r   r    )r>   r   rW   r   r=   BACKGROUND_POSITION_PERCENTAGES)r?   Ztoken_1Ztoken_2r   r   r   r   r&   r&   r'   r     s,    

r   c             C   s\   t tt| }|dkrdS |dkr&dS |dkr6|d S t|dkrXtdd	 |D rX|S d
S )z*``background-repeat`` property validation.repeat-xrepeat	no-repeatrepeat-yspaceroundr   c             s   s   | ]}|dkV  qdS )	no-repeatr   r   r   N)r   r   r   r   r&   )rx   kr&   r&   r'   rz     s   z$background_repeat.<locals>.<genexpr>N)r   )r   r   )r   )r   r   r   r   r   r   )r   r   r   r   )r   r   r=   r>   all)r?   keywordsr&   r&   r'   background_repeat  s    
r   c             C   s   t | dkrP| d }t|}|dkr(|S |dkr4dS t|ddd}|r|dfS nft | d	krg }x@| D ]8}t|ddd}|r|j| qft|dkrf|jd qfW t |d	krt|S d
S )z#Validation for ``background-size``.r   r   containcoverautoFT)rU   rV   r   N)r   r   )r   r   )r>   r=   rW   rJ   r   )r?   r<   rA   r   valuesr&   r&   r'   background_size  s(    

r   zbackground-clipzbackground-originc             C   s   | dkS )z\Validation for the ``<box>`` type used in ``background-clip``
    and ``background-origin``.
border-boxpadding-boxcontent-box)r   r   r   r&   )rA   r&   r&   r'   box  s    r   c             C   sJ   dd | D }t |rFt|dkr2|d |d fS t|dkrFt|S dS )z,Validator for the `border-spacing` property.c             S   s   g | ]}t |d dqS )F)rU   )rW   )rx   r<   r&   r&   r'   r   +  s    z"border_spacing.<locals>.<listcomp>r   r   r   N)r   r>   r   )r?   lengthsr&   r&   r'   border_spacing(  s    r   zborder-top-right-radiuszborder-bottom-right-radiuszborder-bottom-left-radiuszborder-top-left-radiusc             C   sJ   dd | D }t |rFt|dkr2|d |d fS t|dkrFt|S dS )z/Validator for the `border-*-radius` properties.c             S   s   g | ]}t |d ddqS )FT)rU   rV   )rW   )rx   r<   r&   r&   r'   r   :  s    z(border_corner_radius.<locals>.<listcomp>r   r   r   N)r   r>   r   )r?   r   r&   r&   r'   border_corner_radius3  s    r   zborder-top-stylezborder-right-stylezborder-left-stylezborder-bottom-stylezcolumn-rule-stylec             C   s   | dkS )z)``border-*-style`` properties validation.r   hiddendotteddasheddoubleinsetoutsetgrooveridgesolid)
r   r   r   r   r   r   r   r   r   r   r&   )rA   r&   r&   r'   border_styleB  s    r   zoutline-stylec          
   C   s   | d
kS )z(``outline-style`` properties validation.r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r&   )rA   r&   r&   r'   outline_styleN  s    r   zborder-top-widthzborder-right-widthzborder-left-widthzborder-bottom-widthzcolumn-rule-widthzoutline-widthc             C   s,   t | dd}|r|S t| }|dkr(|S dS )z=Border, column rule and outline widths properties validation.F)rU   thinmediumthickN)r   r   r   )rW   r=   )r<   r   rA   r&   r&   r'   border_widthV  s    	r   c             C   s,   t | dd}|r|S t| }|dkr(|S dS )z%``column-width`` property validation.F)rU   r   N)rW   r=   )r<   r   rA   r&   r&   r'   column_widthg  s    r   c             C   s   dS )z$``column-span`` property validation.Nr&   )rA   r&   r&   r'   column_spans  s    r   c             C   s   | dkS )z7Validation for the ``box-sizing`` property from css3-uipadding-box
border-boxcontent-box)r   r   r   r&   )rA   r&   r&   r'   
box_sizing{  s    r   c             C   s   | dkS )z'``caption-side`` properties validation.r   r   )r   r   r&   )rA   r&   r&   r'   caption_side  s    r   c             C   s   | dkS )z``clear`` property validation.r   r    bothr   )r   r    r   r   r&   )rA   r&   r&   r'   clear  s    r   c             C   s   t | }|rx|\}}|dkrxt|dkrxg }x:|D ]2}t|dkrN|jd q2t|}|r2|j| q2W t|dkrx|S t| dkrg S dS )z%Validation for the ``clip`` property.Zrectr   r   N)parse_functionr>   r=   rJ   rW   )r<   r1   r2   rF   r   argr   r&   r&   r'   clip  s    
r   c                s6   t | }|dkr|S  fdd| D }d|kr2|S dS )z ``content`` property validation.normalr   c                s   g | ]}t  |qS r&   )validate_content_token)rx   v)rc   r&   r'   r     s    zcontent.<locals>.<listcomp>N)r   r   )r@   )r?   rc   rA   parsed_tokensr&   )rc   r'   r     s    r   c       	      C   sl  t jt|}|dk	rd|fS |j}|dkr6d|jfS |dkrNdt| |jfS t|}|rh|\}}|dd |D f}dd |D }|dd	gfkr||d
 fS |dd	gfdd	dgffkr|jd ||fS |dd	d	gfdd	dd	gffkr|d }|dks|tj	krh||fS nV|dd	gfdd	d	gffkrht
|dkr`|d j |d< |d dkr`t ||fS dS )zzValidation for a single token for the ``content`` property.

    Return (type, content) or False for invalid tokens.

    NZQUOTESTRINGr   c             S   s   g | ]
}|j qS r&   )r9   )rx   ar&   r&   r'   r     s    z*validate_content_token.<locals>.<listcomp>c             S   s   g | ]}t |d |qS )r:   )getattr)rx   r   r&   r&   r'   r     s    attrr8   r   counterr	   decimalr   r   stringfirststartlastfirst-exceptr   )r   r   )r   r   r   r   )CONTENT_QUOTE_KEYWORDSr\   r=   r9   r:   re   r   rJ   r	   STYLESr>   r;   r!   )	rc   r<   Z
quote_typetype_r1   r2   rF   	prototypestyler&   r&   r'   r     s>    




r   c             C   sv   | j dkrrdd | jD }| s,t|d rrxD|ddd D ]}|j dksT|jdkr<P q<W | jj |ddd fS dS )	zpReturn ``(name, args)`` if the given token is a function
    with comma-separated arguments, or None.
    .
    rv   c             S   s   g | ]}|j d kr|qS )rw   )r9   )rx   ry   r&   r&   r'   r     s    z"parse_function.<locals>.<listcomp>r   r   NDELIM,)r9   r   r>   r:   r   r;   )Zfunction_tokenr   r<   r&   r&   r'   r     s    
r   c             C   s   t | ddS )z*``counter-increment`` property validation.r   )default_integer)r   )r?   r&   r&   r'   counter_increment  s    r  c             C   s   t | ddS )z&``counter-reset`` property validation.r   )r  )r   )r?   r&   r&   r'   counter_reset  s    r  c             C   s   t | dkrg S t| } t| d}|s.tdg }xt|dk	r|jdkrJdS |j}|d	krdtd| t| d}|dk	r|jdkr|j}t| d}n|}|j||f q4W |S )
zB``counter-increment`` and ``counter-reset`` properties validation.r   Nzgot an empty token listr8   initialru   zInvalid counter name: rQ   )r   r  ru   )r@   iternextr+   r9   r:   r!   rJ   )r?   r  r<   rK   Zcounter_nameintegerr&   r&   r'   r     s&    



r   z
margin-topzmargin-rightzmargin-bottomzmargin-leftc             C   s(   t | dd}|r|S t| dkr$dS dS )z#``margin-*`` properties validation.T)rV   r   N)rW   r=   )r<   r   r&   r&   r'   lenght_precentage_or_auto  s
    r	  heightwidthc             C   s*   t | ddd}|r|S t| dkr&dS dS )z7Validation for the ``width`` and ``height`` properties.FT)rU   rV   r   N)rW   r=   )r<   r   r&   r&   r'   width_height!  s
    r  c             C   s,   t | dd}|r|S t| }|dkr(|S dS )z+Validation for the ``column-gap`` property.F)rU   r   N)rW   r=   )r<   r   rA   r&   r&   r'   
column_gap-  s    r  c             C   s   | dkS )z$``column-fill`` property validation.r   balance)r   r  r&   )rA   r&   r&   r'   column_fill9  s    r  c             C   s   | dkS )z"``direction`` property validation.ltrrtl)r  r  r&   )rA   r&   r&   r'   r   @  s    r   c             C   s   | dkS )z ``display`` property validation.inlineblockinline-block	list-itemr   tableinline-tabletable-captiontable-row-grouptable-header-grouptable-footer-group	table-rowtable-column-grouptable-column
table-cell)r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r&   )rA   r&   r&   r'   displayG  s
       r   floatc             C   s   | dkS )z``float`` property validation.r   r    r   )r   r    r   r&   )rA   r&   r&   r'   float_R  s    r"  c             C   sR   t | dkr$| d jdkr$| d jS | rNtdd | D rNdjdd | D S dS )	z$``font-family`` property validation.r   r   r   c             s   s   | ]}|j d kV  qdS )r8   N)r9   )rx   r<   r&   r&   r'   rz   _  s    zfont_family.<locals>.<genexpr> c             s   s   | ]}|j V  qd S )N)r:   )rx   r<   r&   r&   r'   rz   `  s    N)r>   r9   r:   r   join)r?   r&   r&   r'   font_familyY  s    
r%  c             C   s@   t | ddd}|r|S t| }|dkr.td|tjkr<|S dS )	z"``font-size`` property validation.FT)rU   rV   smallerlargerzvalue not supported yetN)r&  r'  )rW   r=   r!   r   ZFONT_SIZE_KEYWORDS)r<   r   Zfont_size_keywordr&   r&   r'   	font_sizec  s    
r(  c             C   s   | dkS )z#``font-style`` property validation.r   italicoblique)r   r)  r*  r&   )rA   r&   r&   r'   
font_styler  s    r+  c          
   C   s   | d
kS )z-Validation for the ``font-stretch`` property.ultra-condensedextra-condensed	condensedsemi-condensedr   semi-expandedexpandedextra-expandedultra-expanded)	r,  r-  r.  r/  r   r0  r1  r2  r3  r&   )rA   r&   r&   r'   font_stretchy  s      r4  c             C   s   | dkS )z%``font-variant`` property validation.r   
small-caps)r   r5  r&   )rA   r&   r&   r'   font_variant  s    r6  c          
   C   s2   t | }|dkr|S | jdkr.| jdkr.| jS dS )z$``font-weight`` property validation.r   boldbolderlighterrQ   r   rY   ,      X         N)r   r7  r8  r9  )	r   rY   r:  r;  r<  r=  r>  r?  r@  )r=   r9   r:   )r<   rA   r&   r&   r'   font_weight  s    

rA  c             C   s   t | S )N)rb   )r<   r&   r&   r'   image_resolution  s    rB  zletter-spacingzword-spacingc             C   s$   t | dkrdS t| }|r |S dS )z7Validation for ``letter-spacing`` and ``word-spacing``.r   N)r=   rW   )r<   r   r&   r&   r'   spacing  s
    rC  c             C   sR   t | dkrdS | jdkr2| jdkr2t| j| jS | jdkrN| jdkrNt| S dS )	z$``line-height`` property validation.r   rR   rQ   
PERCENTAGEr   Z	DIMENSIONN)rR   rQ   rD  )r=   r9   r:   r   rS   rW   )r<   r&   r&   r'   line_height  s    rE  c             C   s   | dkS )z,``list-style-position`` property validation.insideoutside)rF  rG  r&   )rA   r&   r&   r'   list_style_position  s    rH  c             C   s   | dkp| t jkS )z(``list-style-type`` property validation.r   r   )r   r   )r	   r   )rA   r&   r&   r'   list_style_type  s    rI  zpadding-topzpadding-rightzpadding-bottomzpadding-leftz	min-widthz
min-heightc             C   s   t | ddd}|r|S dS )z$``padding-*`` properties validation.FT)rU   rV   N)rW   )r<   r   r&   r&   r'   length_or_precentage  s    	rJ  z	max-widthz
max-heightc             C   s4   t | ddd}|r|S t| dkr0ttddS dS )z'Validation for max-width and max-heightFT)rU   rV   r   infZpxN)rW   r=   r   r!  )r<   r   r&   r&   r'   max_width_height  s
    rL  c             C   s    | j dkrtdtd| jS dS )z(Validation for the ``opacity`` property.rR   rQ   r   r   N)rR   rQ   )r9   minmaxr:   )r<   r&   r&   r'   opacity  s    
rO  c             C   s$   t | dkrdS | jdkr | jS dS )z(Validation for the ``z-index`` property.r   rQ   N)r=   r9   r:   )r<   r&   r&   r'   z_index  s    
rP  ZorphansZwidowsc             C   s    | j dkr| j}|dkr|S dS )z9Validation for the ``orphans`` and ``widows`` properties.rQ   r   N)r9   r:   )r<   r:   r&   r&   r'   orphans_widows  s    
rQ  c             C   s0   | j dkr| j}|dkr|S t| dkr,dS dS )z-Validation for the ``column-count`` property.rQ   r   r   N)r9   r:   r=   )r<   r:   r&   r&   r'   column_count  s    
rR  c             C   s   | dkS )z)Validation for the ``overflow`` property.r   visibler   rf   )r   rS  r   rf   r&   )rA   r&   r&   r'   overflow  s    rT  zpage-break-beforezpage-break-afterc             C   s   | dkS )zWValidation for the ``page-break-before`` and ``page-break-after``
    properties.

    r   alwaysr   r    avoid)r   rU  r   r    rV  r&   )rA   r&   r&   r'   
page_break  s    rW  c             C   s   | dkS )z2Validation for the ``page-break-inside`` property.r   rV  )r   rV  r&   )rA   r&   r&   r'   page_break_inside  s    rX  c             C   s   | dkS )z!``position`` property validation.staticrelativeabsoluterg   )rY  rZ  r[  rg   r&   )rA   r&   r&   r'   r     s    r   c             C   sT   | rPt | d dkrPtdd | D rPdd | D }|ddd |ddd fS dS )	z``quotes`` property validation.r   r   c             s   s   | ]}|j d kV  qdS )r   N)r9   )rx   r   r&   r&   r'   rz   *  s    zquotes.<locals>.<genexpr>c             S   s   g | ]
}|j qS r&   )r:   )rx   r<   r&   r&   r'   r   +  s    zquotes.<locals>.<listcomp>Nr   )r>   r   )r?   stringsr&   r&   r'   quotes&  s    r]  c             C   s   | dkr| S dS )z,Validation for the ``table-layout`` propertyrg   r   N)rg   r   r&   )rA   r&   r&   r'   table_layout1  s    r^  c             C   s   | dkS )z#``text-align`` property validation.r   r    r   justify)r   r    r   r_  r&   )rA   r&   r&   r'   
text_align9  s    r`  c             C   s\   dd | D }|dgkrdS t dd |D rXt|}t|t|krXt|tdg S dS )z(``text-decoration`` property validation.c             S   s   g | ]}t |qS r&   )r=   )rx   r   r&   r&   r'   r   C  s    z#text_decoration.<locals>.<listcomp>r   c             s   s   | ]}|dkV  qdS )	underlineoverlineline-throughblinkN)ra  rb  rc  rd  r&   )rx   rA   r&   r&   r'   rz   F  s   z"text_decoration.<locals>.<genexpr>rd  N)r   setr>   	frozenset)r?   r   uniquer&   r&   r'   text_decoration@  s    

rh  c             C   s   t | dd}|r|S dS )z$``text-indent`` property validation.T)rV   N)rW   )r<   r   r&   r&   r'   text_indentP  s    ri  c             C   s   | dkS )z#``text-align`` property validation.r   	uppercase	lowercase
capitalize
full-width)r   rj  rk  rl  rm  r&   )rA   r&   r&   r'   text_transformY  s    rn  c          	   C   s,   t | dd}|r|S t| }|dkr(|S dS )z.Validation for the ``vertical-align`` propertyT)rV   baselinemiddlesubsupertext-toptext-bottomr   r   N)ro  rp  rq  rr  rs  rt  r   r   )rW   r=   )r<   r   rA   r&   r&   r'   vertical_aligna  s    ru  c             C   s   | dkS )z$``white-space`` property validation.rS  r   ro   )rS  r   ro   r&   )rA   r&   r&   r'   
visibilityn  s    rv  c             C   s   | dkS )z$``white-space`` property validation.r   prenowrappre-wrappre-line)r   rw  rx  ry  rz  r&   )rA   r&   r&   r'   white_spaceu  s    r{  c             C   s   | dkS )z&``overflow-wrap`` property validation.r   
break-word)r   r|  r&   )rA   r&   r&   r'   overflow_wrap|  s    r}  c             C   s   | dkS )z#Validation for ``image-rendering``.r   crisp-edges	pixelated)r   r~  r  r&   )rA   r&   r&   r'   image_rendering  s    r  c       	      C   s  dd | D }t |rFt|dkr2|d |d fS t|dkrFt|S dd | D }t|dkr|d }|tjkr|tj| S |dkrtjS |d	krtjd
d
d S t|dkr|d dkr|\}}n|d dkr|\}}nd
}|tjkrtj| }|dkr|S |\}}||fS d
S )z[``size`` property validation.

    See http://www.w3.org/TR/css3-page/#page-size-prop

    c             S   s   g | ]}t |d dqS )F)rU   )rW   )rx   r<   r&   r&   r'   r     s    zsize.<locals>.<listcomp>r   r   r   c             S   s   g | ]}t |qS r&   )r=   )rx   r   r&   r&   r'   r     s    r   portrait	landscapeN)r   r  r   )r  r  )r  r  )r   r>   r   r   Z
PAGE_SIZESZINITIAL_PAGE_SIZE)	r?   r   r   rA   ZorientationZ	page_sizer  r
  r  r&   r&   r'   r     s6    





r   )r3   c             C   sb   t | dkrdS t| }|r^|\}}|dd |D f}dd |D }|ddgfkr^||d fS dS )	zValidation for ``anchor``.r   c             S   s   g | ]
}|j qS r&   )r9   )rx   r   r&   r&   r'   r     s    zanchor.<locals>.<listcomp>c             S   s   g | ]}t |d |qS )r:   )r   )rx   r   r&   r&   r'   r     s    r   r8   r   N)r=   r   )r<   r1   r2   rF   r   r&   r&   r'   anchor  s    r  )r3   r-   c             C   s   t | dkrdS | jdkrL| jjdr<dt| jdd fS dt|| jfS t| }|r|\}}|dd	 |D f}d
d	 |D }|ddgfkr||d fS dS )zValidation for ``link``.r   r   #Zinternalr   NZexternalc             S   s   g | ]
}|j qS r&   )r9   )rx   r   r&   r&   r'   r     s    zlink.<locals>.<listcomp>c             S   s   g | ]}t |d |qS )r:   )r   )rx   r   r&   r&   r'   r     s    r   r8   r   )r=   r9   r:   
startswithr   re   r   )r<   rc   r1   r2   rF   r   r&   r&   r'   link  s    
r  c             C   s(   | j dkr| j}|dkr|S t| ddS )zVValidation for ``tab-size``.

    See https://www.w3.org/TR/css-text-3/#tab-size

    rQ   r   F)rU   )r9   r:   rW   )r<   r:   r&   r&   r'   tab_size  s
    
r  c             C   s   t | }|dkr|S dS )zValidation for ``hyphens``.r   manualr   N)r   r  r   )r=   )r<   rA   r&   r&   r'   hyphens  s    r  c             C   s(   t | }|dkrdS | jdkr$| jS dS )z'Validation for ``hyphenate-character``.r   u   ‐r   N)r=   r9   r:   )r<   rA   r&   r&   r'   hyphenate_character  s
    
r  c             C   s   t | dddS )z(Validation for ``hyphenate-limit-zone``.FT)rU   rV   )rW   )r<   r&   r&   r'   hyphenate_limit_zone  s    r  c             C   s  t | dkr@| \}t|}|dkr&dS |jdkr<|jddfS n>t | dkr| \}}t|}t|}|jdkr|jdkr|j|j|jfS |dkr|jddfS n,|dkr|jdkrd|j|jfS |dkrd	S nt | dkr~| \}}}t|dk s|jdkr~t|dks|jdkr~t|dks2|jdkr~|jdkrD|jnd}|jdkrZ|jnd}|jdkrp|jnd}|||fS dS )
z)Validation for ``hyphenate-limit-chars``.r   r      r   rQ   r   N)r  r   r   )r  r   r   )r>   r=   r9   r:   )r?   r<   rA   totalr   Ztotal_keywordZleft_keywordr    r&   r&   r'   hyphenate_limit_chars  s<    




r  c             C   sx   t | dkrdS t| }|r`|\}}|dd |D f}dd |D }|ddgfkrt||d fS n| jdkrtd	| jfS d
S )zValidation for ``lang``.r   c             S   s   g | ]
}|j qS r&   )r9   )rx   r   r&   r&   r'   r   -  s    zlang.<locals>.<listcomp>c             S   s   g | ]}t |d |qS )r:   )r   )rx   r   r&   r&   r'   r   .  s    r   r8   r   r   r   N)r=   r   r9   r:   )r<   r1   r2   rF   r   r&   r&   r'   lang$  s    
r  c             C   s   dd | D }d|kr|S dS )z"Validation for ``bookmark-label``.c             S   s   g | ]}t |qS r&   )validate_content_list_token)rx   r   r&   r&   r'   r   8  s    z"bookmark_label.<locals>.<listcomp>Nr&   )r?   r   r&   r&   r'   bookmark_label5  s    r  c             C   s2   | j dkr| j}|dkr.|S nt| dkr.dS dS )z"Validation for ``bookmark-level``.rQ   r   r   N)r9   r:   r=   )r<   r:   r&   r&   r'   bookmark_level=  s    
r  c             C   sZ   t | dkr@t| d }dd | dd D }d|krV||fS n| rV| d jdkrVdS dS )zValidation for ``string-set``.r   r   c             S   s   g | ]}t |qS r&   )r  )rx   r   r&   r&   r'   r   O  s    zstring_set.<locals>.<listcomp>r   Nr   )r>   r=   r:   )r?   var_namer   r&   r&   r'   
string_setI  s    
r  c             C   s  | j }|dkrd| jfS t| }|r|\}}|dd |D f}dd |D }|ddgfkrh||d fS |dg fddgffkr|s|d	fS |d dkr||d fS nr|ddgfdddgffkr|jd ||fS |dddgfddddgffkr|d }|dks|tjkr||fS dS )z|Validation for a single token of <content-list> used in GCPM.

    Return (type, content) or False for invalid tokens.

    r   c             S   s   g | ]
}|j qS r&   )r9   )rx   r   r&   r&   r'   r   b  s    z/validate_content_list_token.<locals>.<listcomp>c             S   s   g | ]}t |d |qS )r:   )r   )rx   r   r&   r&   r'   r   c  s    r   r8   r   r   textafterbeforer   r	   r   r   r   N)r  r  r  r   )r   r   )r9   r:   r   rJ   r	   r   )r<   r   r1   r2   rF   r   r   r&   r&   r'   r  V  s0    


r  c             C   s"   t | dkrg S dd | D S d S )Nr   c             S   s   g | ]}t |qS r&   )transform_function)rx   r   r&   r&   r'   r   |  s    ztransform.<locals>.<listcomp>)r@   )r?   r&   r&   r'   	transformw  s    r  c             C   s  t | }|st|\}}t|dkr
t|d }t|d dd}|dkrV|rV||fS |dkrp|rpd	|tjffS |d
kr|rd	tj|ffS |dkr|d jdkrd|d jdffS |dkr|d jdkrdd|d jffS |dkr|d jdkrd|d jfd fS nt|dkrx|dkrHt	dd |D rH|dd |D fS t
dd |D }|d	krt	|r||fS n>t|dkr|dkrt	dd |D r|dd |D fS td S )Nr   r   T)rV   rotateskewxskewy
translatex	translateZ
translateyZscalexrR   rQ   ZscaleZscaleyr   c             s   s   | ]}|j dkV  qdS )rR   rQ   N)rR   rQ   )r9   )rx   r   r&   r&   r'   rz     s   z%transform_function.<locals>.<genexpr>c             S   s   g | ]
}|j qS r&   )r:   )rx   r   r&   r&   r'   r     s    z&transform_function.<locals>.<listcomp>c             s   s   | ]}t |d dV  qdS )T)rV   N)rW   )rx   r<   r&   r&   r'   rz     s       Zmatrixc             s   s   | ]}|j dkV  qdS )rR   rQ   N)rR   rQ   )r9   )rx   r   r&   r&   r'   rz     s    c             S   s   g | ]
}|j qS r&   )r:   )rx   r   r&   r&   r'   r     s    )r  r  r  )r  r  )rR   rQ   )rR   rQ   )rR   rQ   )r   r!   r>   r^   rW   r   ZZERO_PIXELSr9   r:   r   r   )r<   r1   r2   rF   r   r   r   r&   r&   r'   r    s<    
r  c                s    fdd}|S )z1Decorator adding a function to the ``EXPANDERS``.c                s    t kst | t  < | S )z&Add ``function`` to the ``EXPANDERS``.)	EXPANDERSr+   )r1   )r4   r&   r'   expander_decorator  s    z$expander.<locals>.expander_decoratorr&   )r4   r  r&   )r4   r'   expander  s    r  zborder-colorzborder-stylezborder-widthmarginpaddingc             c   s   t |dkr|d9 }nNt |dkr,|d9 }n8t |dkrH|j|d  nt |dkrdtdt | xhtd|D ]Z\}}|jd
}|dkr|| }n|d| | ||d  }t| ||gdd\}|V  qpW dS )z>Expand properties setting a token for the four sides of a box.r   r   r   r   z'Expected 1 to 4 token components got %i-top-right-bottom-leftr)   NT)required)r  r  r  r  r   )r>   rJ   r!   ziprfindvalidate_non_shorthand)rc   r2   r?   suffixr<   inew_namerM   r&   r&   r'   expand_four_sides  s"    



r  zborder-radiusc             c   s4  g  }}g }xX|D ]P}|j dkrX|jdkrX||krN||d krHtdqV|}qbtdq|j| qW |sv|dd }xt||fD ]h}t|dkr|d9 }qt|dkr|d9 }qt|d	kr|j|d  qt|dkrtd
t| qW d}x>t|t||D ]*\}	}d|	 }
t| |
|dd\}|V  qW dS )z+Validator for the `border-radius` property.r   /r   z"Expected value after "/" separatorzExpected only one "/" separatorNr   r   r   z'Expected 1 to 4 token components got %itop-left	top-rightbottom-rightbottom-leftzborder-%s-radiusT)r  r   )r  r  r  r  )r9   r:   r!   rJ   r>   r  r  )rc   r2   r?   currentZ
horizontalZverticalr<   r   Zcornersr   r  rM   r&   r&   r'   border_radius  s8    




r  c                 s(   |j dd| st fdd}|S )zDecorator helping expanders to handle ``inherit`` and ``initial``.

    Wrap an expander so that it does not have to handle the 'inherit' and
    'initial' cases, and can just yield name suffixes. Missing suffixes
    get the initial value.

    r-   Fc                s   t j  fdd}|S )z"Decorate the ``wrapped`` expander.c             3   s   t |}|d	kr"tj |}d}nld}i }r<||| }n
||}xF|D ]>\}}| ksdt|||krtd|jd|f |||< qLW x^ D ]V}|jdr|| }	n|}	||kr|| }
|st| |	|
dd\\}	}
nd}
|	|
fV  qW dS )
zWrap the expander.ru   r  TFz(got multiple %s values in a %s shorthandr)   )r  N)ru   r  )r@   dictfromkeysr+   r!   stripr  r  )rc   r2   r?   rA   rK   Zskip_validationrM   r  Z	new_tokenZactual_new_namer:   )expanded_namesr-   wrappedr&   r'   generic_expander_wrapper  s6    



zVgeneric_expander.<locals>.generic_expander_decorator.<locals>.generic_expander_wrapper)rC   rD   )r  r  )r  r-   )r  r'   generic_expander_decorator  s    'z4generic_expander.<locals>.generic_expander_decorator)r   r+   )r  kwargsr  r&   )r  r-   r'   generic_expander  s    
*r  z
list-stylez-typez	-positionz-imagec       	      c   s   d }}d}x||D ]t}t |dkr0|d7 }|}qt|gdk	rHd}d}n2t|gdk	r\d}nt|g|dk	rvd	}d}nt||gfV  qW | r|rd|gfV  |d8 }| r|rd	|gfV  |d8 }|rtdS )
zxExpand the ``list-style`` shorthand property.

    See http://www.w3.org/TR/CSS21/generate.html#propdef-list-style

    Fr   r   r   Nz-typeTz	-positionz-image)r=   rI  rH  r   r!   )	r2   r?   rc   Ztype_specifiedZimage_specifiedZ
none_countr<   Z
none_tokenr  r&   r&   r'   expand_list_style2  s2    


r  Zborderc             c   s2   x,dD ]$}xt | || |D ]
}|V  qW qW dS )zkExpand the ``border`` shorthand property.

    See http://www.w3.org/TR/CSS21/box.html#propdef-border

    -top-right-bottom-leftN)r  r  r  r  )expand_border_side)rc   r2   r?   r  Znew_propr&   r&   r'   expand_border]  s    
r  z
border-topzborder-rightzborder-bottomzborder-leftzcolumn-ruleoutlinez-widthz-colorz-stylec             c   s\   xV|D ]N}t |dk	rd}n,t|gdk	r0d}nt|gdk	rDd}nt||gfV  qW dS )zsExpand the ``border-*`` shorthand properties.

    See http://www.w3.org/TR/CSS21/box.html#propdef-border-top

    Nz-colorz-widthz-style)r   r   r   r!   )r2   r?   r<   r  r&   r&   r'   r  i  s    
r  Z
backgroundc             #   s   ddddddddgt |}|dkr@xD ]}||fV  q*W dS d fdd	}tt|}|t|dd\}}tdd |j D }x<|D ]4}||\}	}
x"|
j D ]\}}|| j| qW qW x(|j D ]\}}||ddd fV  qW d|fV  dS )ztExpand the ``background`` shorthand property.

    See http://dev.w3.org/csswg/css3-background/#the-background

    background_colorr   r   ri   r   r   Zbackground_clipZbackground_originr  ru   NFc                sn  i   fdd}| d d d } x
| r*|dt j| dd  d d d rV| dd = q"| dd  }|r~|dt|r~| j  q"|dtj|r| j  q"|dt j|r| j  q"|dtj|r| j  q" xdt|  d  D ]}| | d  d d d }tj|}|d k	r|d|s"t| | d = | r| d j	dkr| d j
dkrxddt|  d  D ]N}| | d d d d }tj|}|d k	rh|d|st| | d = qhW P qW |d k	rq"|dtj|r$| j  | dd  }|dtj|r| j  q"|dtj|s"tq"tq"W  jdtd }	x(D ] }
|
 krBt|
 d  |
< qBW |	 fS ) Nc                s,   |d krdS d|  } |  kr t | | < dS )NFZbackground_T)r!   )r2   r:   )rK   r&   r'   r/     s    z3expand_background.<locals>.parse_layer.<locals>.addr   r   r   rt   image
attachmentr   r   r   r   r  r   originr   r  r   r   r   r  r   )r   r   r   r   r   r   r   )r   r   r   r   r   )r   rO   rj   r   r   ri   r>   r   r+   r9   r:   r   r   r!   r   )r?   final_layerr/   r<   nZn_tokensr   r   Z
next_tokenrt   r2   )rc   
properties)rK   r'   parse_layer  sh    









z&expand_background.<locals>.parse_layerT)r  c             s   s   | ]\}}||gfV  qd S )Nr&   )rx   r   r   r&   r&   r'   rz     s    z$expand_background.<locals>.<genexpr>r   zbackground-color)r  ru   )Fr   )r@   reversedr   r  r  itemsrJ   )rc   r2   r?   rA   r  Zlayersrt   Z
last_layerrK   r(   Zlayerr:   r   r&   )rc   r  r'   expand_background  s&    
D
r  columnszcolumn-widthzcolumn-countc             c   s   d} t |dkr.t|d dkr.|ddd }xL|D ]D}t|gdk	rT| dkrTd} nt|gdk	rhd} nt| |gfV  q4W dS )	z*Expand the ``columns`` shorthand property.Nr   r   r   r   zcolumn-widthzcolumn-countr   )r>   r=   r   rR  r!   )r2   r?   r<   r&   r&   r'   expand_columns  s    
r  Zfontz-variantz-weightz-stretchz-sizezline-heightz-familyc             c   sB  t |}|dkrtdtt|}x||r|j }t|dkr@q&t|gd	k	rTd
}n>t|gd	k	rhd}n*t|gd	k	r|d}nt	|gd	k	rd}nP ||gfV  q&W t
|gd	krtd|gfV  |st|j }|jdko|jdkr|j }t|gd	krtd|gfV  n
|j| |j  t|d	kr4td|fV  d	S )zfExpand the ``font`` shorthand property.

    http://www.w3.org/TR/CSS21/fonts.html#font-shorthand
    captioniconmenumessage-boxsmall-caption
status-barzSystem fonts are not supportedr   Nz-stylez-variantz-weightz-stretchz-sizer   r  zline-heightz-family)r  r  r  r  r  r  )r@   r!   listr  r   r=   r+  r6  rA  r4  r(  r9   r:   rE  rJ   reverser%  )r2   r?   Zexpand_font_keywordr<   r  r&   r&   r'   expand_font  sF    
r  z	word-wrapc             c   s"   t |}|dkrtd|fV  dS )zmExpand the ``word-wrap`` legacy property.

    See http://http://www.w3.org/TR/css3-text/#overflow-wrap

    Nzoverflow-wrap)r}  r!   )rc   r2   r?   rA   r&   r&   r'   expand_word_wrap6  s    r  c             C   s   | r8|t kr8|jdd}|t kr0td| ntd| rN|tkrNtdt|}|d	krd|}n.t| }|jr~||| }n||}|dkrt||fgS )
z/Default validator for non-shorthand properties.r(   r)   zdid you mean %s?zunknown propertyzproperty not supported yetr  ru   N)r  ru   )r   r*   r!   r,   r@   r-   )rc   r2   r?   r  Zhyphens_namerA   r:   r1   r&   r&   r'   r  D  s"    r  c             #   sF   fdd}x2|D ](  j }|tkrH|jt rH|ddt |  q|tkr\|dd q|jtr|ttd }|tkr|dd|  q|tkr|}tj|t	}t
 j}yt|| ||}W nJ tk
r } z,|d|jr|jd	 r|jd	 nd
 wW Y dd}~X nX  j}	x&|D ]\}
}|
jdd||	fV  qW qW dS )z
    Expand shorthand properties and filter unsupported properties and values.

    Log a warning for every ignored declaration.

    Return a iterable of ``(name, value, priority)`` tuples.

    c                s(   t t| d j jj  j j| d S )NzIgnored `%s: %s` at %i:%i, %s.)r   r   r2   r:   Zas_csslinecolumn)levelreason)declarationr&   r'   validation_errorg  s    z1preprocess_declarations.<locals>.validation_errorwarningz4the property is experimental or non-standard, use %sinfoz/the property does not apply for the print mediaNz!the property was unprefixed, use r   zinvalid valuer)   r(   )r2   r.   r  PREFIXr   r>   r0   r  r\   r  r   r:   r  r!   rF   priorityr*   )rc   Zdeclarationsr  r2   Zunprefixed_nameZ	expander_r?   rM   excr  Z	long_namer:   r&   )r  r'   preprocess_declarations^  sD    	


 r  )TT)FT)TF)FF)NFFF)TF)r   r   )r   r   )r   r    )r   r   )r   r   )r   r   r   )r   r   )r   r   r   )r   r   )r   r   r    )r   r   )r   r    r   )r   r   )r   r   r   )r   r   )r   r   r   )r   r   )r   r   r    )r   r   )r   r    r   )r   r   )F)r%   
__future__r   r   rC   r   Ztinycss.color3r   Ztinycss.parsingr   r   loggerr   Zformatting_structurer	   compatr
   r   Zurlsr   r   Zimagesr   r   r  r   r   r   r    r   re  ZLENGTHS_TO_PIXELSrT   r   r   r   ZHUNDRED_PERCENTr   r,   r  r.   r0   r  
ValueErrorr!   r7   r=   r@   rE   rI   rP   rW   r   r[   r^   ra   rb   re   ri   rj   rm   rp   rs   rt   r   r   r   r   r}   r   objectr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r	  r  r  r  r   r   r"  r%  r(  r+  r4  r6  rA  rB  rC  rE  rH  rI  rJ  rL  rO  rP  rQ  rR  rT  rW  rX  r   r]  r^  r`  rh  ri  rn  ru  rv  r{  r}  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&   r&   r&   r'   <module>   s6  




 )
	


+
	1(


		

			(




%


!(
)8$**a@