3
VmW"              *   @   s  d Z ddlmZmZ ddlZddgZeddded	ed
fddZdeiZ	i Z
dddZdd Zedd Zedd Zedd Zedd Zedd Zedd Zedddd j fd! ed"dddddddddddddddgd= ed>dddddddddddddddgd= edLddddddddddddddddddddddddddddddd ddddddddg%d= edd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'd(d)d*d+d,d-g$d= edddj d! edddj d! edddj d! edddgdd edddgdd edddgdd edddd edddd dd Zdd ZdS (.  a  
    weasyprint.formatting_structure.counters
    ----------------------------------------

    Implement the various counter types and list-style-type values.

    These are defined in the same terms as CSS 3 Lists:
    http://dev.w3.org/csswg/css3-lists/#predefined-counters

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

    )divisionunicode_literalsNformatformat_list_marker- .z-infinfdecimal)negativeprefixsuffixrangefallbacksymbolicc          	   K   s^   |dkrt t|jd }n,t ttjt| |jd|jdtd d}|j| |t| < dS )zRegister a counter style.overridesymbolsr   )	formatterN)dictSTYLESpopINITIAL_VALUES	functoolspartial
FORMATTERSupdate)nametypeZdescriptorsstyle r   h/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/weasyprint/formatting_structure/counters.pyregister_style1   s    
r!   c             C   s   | t | jjdd< | S )z"Register a counter type/algorithm._r   )r   __name__replace)functionr   r   r    register_formatter@   s    r&   c             C   s   | |d t |   S )z.Implement the algorithm for `type: repeating`.   )len)r   	_negativevaluer   r   r    	repeatingF   s    r+   c             C   s   |dkr| d S |dk }|r4t |}|\}}|g}ng }t| }t |}x&|dkrn|j| ||   || }qJW |r~|j| djt|S )z,Implement the algorithm for `type: numeric`.r   r   )absr(   appendjoinreversed)r   r   r*   is_negativer   r   reversed_partslengthr   r   r    numericL   s     

r3   c             C   sV   |dkrdS t | }g }x.|dkrF|d8 }|j| ||   || }qW djt|S )z/Implement the algorithm for `type: alphabetic`.r   Nr'   r   )r(   r-   r.   r/   )r   r)   r*   r2   r1   r   r   r    
alphabeticb   s    
r4   c             C   s,   |dkrdS t | }| ||  |d |  S )z-Implement the algorithm for `type: symbolic`.r   Nr'   )r(   )r   r)   r*   r2   r   r   r    r   p   s    c             C   s8   | \}} ||8 }d|  ko&t | k n  r4| | S dS )z2Implement the algorithm for `type: non-repeating`.r   N)r(   )r   r)   r*   Zfirst_symbol_valuer   r   r    non_repeatingy   s    r5   c       
      C   s   |dkr&x| D ]\}}|dkr|S qW |dk }|rJt |}|\}}|g}ng }xT| D ]L\}}|| }	|j|g|	  |||	 8 }|dkrT|r|j| dj|S qTW dS )z-Implement the algorithm for `type: additive`.r   r   N)r,   extendr-   r.   )
r   r   r*   Zweightsymbolr0   r   r   partsZrepetitionsr   r   r    additive   s&    
r9   zdecimal-leading-zeroznon-repeating	   zU-09 -08 -07 -06 -05 -04 -03 -02 -01
                    00 01 02 03 04 05 06 07 08 09)r   r   zlower-romanr'       m  cm  d  cdd   cZ   xc2   l(   xl
   xix   v   ivi)r   r   r   zupper-romanMCMDCDCXCLXLXIXVIVIZgeorgianN  '     ჵ(#     ჰ@     ჯX     ჴp     ხ     ჭ     წ     ძ     ც   ჩ   შ      ყ     ღX     ქ   ფ   ჳ,     ტ      ს   რ   ჟP      პF      ო<      ჲ   ნ   მ      ლ      კ   ი   თ      ჱ      ზ      ვ   ე   დ      გ      ბ   აZarmenian'     Ք   Փ   Ւ   Ց   Ր   Տ   Վ   Ս   Ռ   Ջ   Պ   Չ   Ո   Շ   Ն   Յ   Մ   Ճ   Ղ   Ձ   Հ   Կ   Ծ   Խ   Լ   Ի   Ժ   Թ   Ը   Է   Զ   Ե   Դ   Գ   Բ   Աzlower-alphaz3a b c d e f g h i j k l m n o p q r s t u v w x y zzupper-alphaz3A B C D E F G H I J K L M N O P Q R S T U V W X Y Zzlower-greekuG   α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ωZdiscu   •)r   r   r   Zcircleu   ◦Zsquareu   ▪zlower-latinr   )r   r   zupper-latinc             C   s   |dkrdS t  }xr|dks$||kr,t| S t| }|d \}}||   koR|kn  rp|d | }|dk	rp|S |j| |d }qW dS )z
    Return a representation of ``value`` formatted by ``counter_style``
    or one of its fallback.

    The representation includes negative signs, but not the prefix and suffix.

    Znoner   r
   r   r   Nr   )setstrr   add)r*   counter_styleZfailed_stylesr   lowhighZrepresentationr   r   r    r     s    
c             C   s"   t | }|d t| | |d  S )u   
    Return a representation of ``value`` formatted for a list marker.

    This is the same as :func:`format()`, but includes the counter’s
    prefix and suffix.
    r   r   )r   r   )r*   r   r   r   r   r    r     s    )r   r   )r   i)r'   r;   )r<   r=   )r>   r?   )r@   rA   )rB   rC   )rD   rE   )rF   rG   )rH   rI   )rJ   rK   )rL   rM   )r:   rN   )rO   rP   )rQ   rR   )r'   rS   )r'   r;   )r<   rT   )r>   rU   )r@   rV   )rB   rW   )rD   rX   )rF   rY   )rH   rZ   )rJ   r[   )rL   r\   )r:   r]   )rO   r^   )rQ   r_   )r'   r`   )r'   ra   )rb   rc   )rd   re   )rf   rg   )rh   ri   )rj   rk   )rl   rm   )rn   ro   )rp   rq   )rr   rs   )r<   rt   )r>   ru   )rv   rw   )rx   ry   )rz   r{   )r@   r|   )rB   r}   )r~   r   )r   r   )rD   r   )rF   r   )r   r   )r   r   )r   r   )rH   r   )rJ   r   )r   r   )r   r   )rL   r   )r:   r   )r   r   )r   r   )r   r   )rO   r   )rQ   r   )r   r   )r   r   )r'   r   )r'   r   )rd   r   )rf   r   )rh   r   )rj   r   )rl   r   )rn   r   )rp   r   )rr   r   )r<   r   )r>   r   )rv   r   )rx   r   )rz   r   )r@   r   )rB   r   )r~   r   )r   r   )rD   r   )rF   r   )r   r   )r   r   )r   r   )rH   r   )rJ   r   )r   r   )r   r   )rL   r   )r:   r   )r   r   )r   r   )r   r   )rO   r   )rQ   r   )r   r   )r   r   )r'   r   )__doc__
__future__r   r   r   __all__r   floatr   r   r   r!   r&   r+   r3   r4   r   r5   r9   splitr   r   r   r   r   r    <module>   s   	
		 





