
    Kwg%                         d Z dZdj                         Zg dZdZd Zd Zd Zd Z	d	 Z
eeee	e
d
Z G d d      Z G d d      Z	 dad Zd Zd ZddlmZ  ee       [d Zedk(  r e        yy)z3.3.0zHA Sequencer class counts things. It aids numbering and formatting lists.z#Sequencer getSequencer setSequencer)
       	   I   
            iI     IVXLCDMc                     | dk  s| dkD  rt        d      d}d}| rCt        | d      \  } }t        |   }|r!t        |d      \  }}t        ||z      |z   }|r!|dz  }| rC|S )	Nr   i  zillegal value r      r   )
ValueErrordivmod_RN_TEMPLATES_RN_LETTERS)valuestrbaseindextmps        N/var/www/horilla/myenv/lib/python3.12/site-packages/reportlab/lib/sequencer.py	_format_Ir      s    qyEDL))
CD
eR(uE"QJCeDj)C/C  		  J    c                 4    t        |       j                         S N)r   lowernums    r   	_format_ir!      s    S>!!r   c                     t        |       S )zThe simplest formatter)r   r   s    r   _format_123r#   "   s    s8Or   c                 .    | dz
  dz  }t        |dz         S )zUppercase.  Wraps around at 26.r      A   chrr    ns     r   _format_ABCr+   &       	a2Aqt9r   c                 .    | dz
  dz  }t        |dz         S )zLowercase.  Wraps around at 26.r   r%   a   r'   r)   s     r   _format_abcr/   +   r,   r   )Ii1Aac                   F    e Zd ZdZd Zd ZddZd ZeZd Z	d Z
d	 Zd
 Zy)_Countera  Private class used by Sequencer.  Each counter
    knows its format, and the IDs of anything it
    resets, as well as its value. Starts at zero
    and increments just before you get the new value,
    so that it is still 'Chapter 5' and not 'Chapter 6'
    when you print 'Figure 5.1'c                 X    d| _         | j                   | _        t        | _        g | _        y Nr   )_base_valuer#   
_formatter_resetsselfs    r   __init__z_Counter.__init__@   s"    
jj%r   c                     || _         y r   )r;   )r>   
formatFuncs     r   setFormatterz_Counter.setFormatterF   s	    $r   Nc                 :    |r|| _         y | j                  | _         y r   )r:   r9   )r>   r   s     r   resetz_Counter.resetI   s    DK**DKr   c                     | xj                   dz  c_         | j                   }| j                  D ]  }|j                           |S )Nr   )r:   r<   rD   )r>   vcounters      r   nextz_Counter.nextO   s:    qKK|| 	GMMO	r   c                     | j                   S r   )r:   r=   s    r   _thisz_Counter._thisW   s    {{r   c                 6    | j                  t        |             S )zReturns next value formatted)r;   rH   r=   s    r   nextfz_Counter.nextfZ   s    tDz**r   c                 @    | j                  | j                               S r   )r;   rJ   r=   s    r   thisfz_Counter.thisf^   s    tzz|,,r   c                 X    || j                   vr| j                   j                  |       y y r   )r<   append)r>   otherCounters     r   chainz_Counter.chaina   s%    t||+LL- ,r   r   )__name__
__module____qualname____doc__r?   rB   rD   rH   __next__rJ   rL   rN   rR    r   r   r6   r6   8   s6    #%% H+-.r   r6   c                   ~    e Zd ZdZd Zd ZddZddZd ZddZ	dd	Z
dd
ZddZd Zd ZddZd Zd Zd Zd Zy)	Sequenceran  Something to make it easy to number paragraphs, sections,
    images and anything else.  The features include registering
    new string formats for sequences, and 'chains' whereby
    some counters are reset when their parents.
    It keeps track of a number of
    'counters', which are created on request:
    Usage::
    
        >>> seq = layout.Sequencer()
        >>> seq.next('Bullets')
        1
        >>> seq.next('Bullets')
        2
        >>> seq.next('Bullets')
        3
        >>> seq.reset('Bullets')
        >>> seq.next('Bullets')
        1
        >>> seq.next('Figures')
        1
        >>>
    c                 @    i | _         i | _        | j                          y r   )	_counters_formatters_resetr=   s    r   r?   zSequencer.__init__}   s    r   c                    | j                   j                          | j                  j                          | j                  j                  t        t
        t        t        t        d       t        | j                   | j                        }| j                  j                          | j                  j                  |       d | _        y )N)r2   r3   r4   r0   r1   )r\   r]   )r\   clearr]   updater#   r+   r/   r   r!   dict__dict___defaultCounter)r>   ds     r   r^   zSequencer._reset   s     ! 	 4>>d6F6FGQ#r   Nc                 v    	 | j                   |   S # t        $ r t               }|| j                   |<   |cY S w xY w)zCreates one if not present)r\   KeyErrorr6   )r>   rG   cnts      r   _getCounterzSequencer._getCounter   s?    	>>'** 	*C&)DNN7#J	s    $88c                 \    |s| j                   }| j                  |      j                         S )z_Retrieves counter value but does not increment. For
        new counters, sets base value to 1.)rd   ri   rJ   r>   rG   s     r   rJ   zSequencer._this   ,     **G(..00r   c                 J    t        | j                  | j                              S zqRetrieves the numeric value for the given counter, then
        increments it by one.  New counters start at one.)rH   ri   rd   r=   s    r   rW   zSequencer.__next__   s      D$$T%9%9:;;r   c                     |st        |       S | j                  }	 || _        t        |       || _        S # || _        w xY wr   )rH   rd   )r>   rG   dcs      r   rH   zSequencer.next   s?    :%%B*'.$Dz')$r$s   4 	=c                 \    |s| j                   }| j                  |      j                         S r   )rd   ri   rN   rk   s     r   rN   zSequencer.thisf   s*    **G(..00r   c                 \    |s| j                   }| j                  |      j                         S rn   )rd   ri   rL   rk   s     r   rL   zSequencer.nextf   rl   r   c                     || _         y)z$Changes the key used for the defaultN)rd   )r>   defaults     r   setDefaultCounterzSequencer.setDefaultCounter   s
    &r   c                 "    || j                   |<   y)zRegisters a new formatting function.  The funtion
        must take a number as argument and return a string;
        fmt is a short menmonic string used to access it.N)r]   )r>   formatfuncs      r   registerFormatzSequencer.registerFormat   s     $( r   c                 b    | j                   |   }| j                  |      j                  |       y)zPSpecifies that the given counter should use
        the given format henceforth.N)r]   ri   rB   )r>   rG   rw   rx   s       r   	setFormatzSequencer.setFormat   s-     '!..t4r   c                 L    |s| j                   }|| j                  |      _        y r   )rd   ri   r:   )r>   rG   r   s      r   rD   zSequencer.reset   s#    **G+/!(r   c                 j    | j                  |      }| j                  |      }|j                  |       y r   )ri   rR   )r>   parentchildpcs        r   rR   zSequencer.chain   s-    V$U#	
r   c                 `    |dd dk(  r|dd }| j                  |      S | j                  |      S )zrAllows compact notation to support the format function.
        s['key'] gets current value, s['key+'] increments.r   N+)rL   rN   )r>   keyrG   s      r   __getitem__zSequencer.__getitem__   s9     rs8s?#2hG::g&&::c?"r   c                     || z  S )z0The crowning jewels - formats multi-level lists.rX   )r>   templates     r   rw   zSequencer.format   s    $r   c           	         t        | j                  j                               }|j                          t	        d       |D ]=  \  }}t	        d||j                         |j                  |j                         fz         ? y)z-Write current state to stdout for diagnosticszSequencer dump:z2    %s: value = %d, base = %d, format example = %sN)listr\   itemssortprintrJ   r9   rN   )r>   countersr   rG   s       r   dumpzSequencer.dump   sr    ,,./ & 	GNS'FW]]_gmmW]]_JF F G	Gr   r   r8   )rS   rT   rU   rV   r?   r^   ri   rJ   rW   rH   rN   rL   ru   ry   r{   rD   rR   r   rw   r   rX   r   r   rZ   rZ   e   sX    .
$ 1<
	*1
1'(50

#Gr   rZ   Nc                  .    t         
t               a t         S r   )
_sequencerrZ   rX   r   r   getSequencerr      s    [
r   c                     t         }| a |S r   )r   )seqss     r   setSequencerr      s    AJHr   c                  :    t         rt         j                          y y r   )r   r^   rX   r   r   r^   r^      s     r   r   )register_resetc            
         t               t        dt              t              t              fz         t        dj                  d      j                  d      j                  d      fz         t        dt              z         j                  d       t        dt              t              t              fz         j                          t        dt              t              t              fz         t                t        d       j	                  d	d
       t        dj                  d	      dj                  d	      dj                  d	             d } t                t        d       j                  d|        j	                  dd       t        ddj                  fdt        dd      D              z          t                t        d       j                  dd       t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t        dj                  d      z         t                t        d       t        dd	   z         t        dd   z         t        dd   z         t        dd	   z         t                t        d       t        d        t        d!z         t        d!z         t        d!z         y )"Nz)Counting using default sequence: %d %d %dz1Counting Figures: Figure %d, Figure %d, Figure %dfigurezBack to default again: %dlist1zSet default to list1: %d %d %dz#Set default to None again: %d %d %dz0Creating Appendix counter with format A, B, C...Appendixr3   z    Appendix z, Appendix c                     d| dz
  dz     S )N)undeuxtroisquatrecinqr      rX   r   s    r   format_frenchztest.<locals>.format_french  s    4c!eQY??r   z+Defining a custom format with french words:french
FrenchListz    c              3   R   K   | ]  }t        j                  d                yw)r   N)r   rL   ).0r1   r   s     r   	<genexpr>ztest.<locals>.<genexpr>  s     J!3qww|45Js   $'r      z:Chaining H1 and H2 - H2 goes back to one when H1 increasesH1H2z    H1 = %dz      H2 = %dz-GetItem notation - append a plus to incrementz    seq["Appendix"] = %sz    seq["Appendix+"] = %sz	Appendix+z8Finally, string format notation for nested lists.  Cool!z>The expression ("Figure %(Chapter)s.%(Figure+)s" % seq) gives:z"    Figure %(Chapter)s.%(Figure+)s)
rZ   r   rH   ru   r{   rL   ry   joinrangerR   )r   r   s    @r   testr     s   A	
5aa$q'8R
RS	
=	x!&&*AFF8,<A> > ?	
%Q
/0 	
*d1gd1gtAw-G
GH	
/4747DG2L
LM	G	
<=KK
C 		

 3AGGJ4GI J@	G	
78X}-KKh'	%#((JuQqzJJ
KL	G	
FGGGD	-!&&,
&'	/AFF4L
()	/AFF4L
()	/AFF4L
()	-!&&,
&'	/AFF4L
()	/AFF4L
()	/AFF4L
()	G	
9:	
$q}
45	
%+
67	
%+
67	
$q}
45	G	
DE	
JK	
.
23	
.
23	
.
23r   __main__)__version__rV   split__all__r   r   r   r!   r#   r+   r/   _type2formatterr6   rZ   r   r   r   r^   reportlab.rl_configr   r   rS   rX   r   r   <module>r      s    V1779 N"
 
+. +.ZGG GGR .

 / v -4` ZF r   