
    Q?h                     X    S r SSKJrJrJr  SSKJr  S r " S S\5      r " S S5      r	g	)
zHhelper for importing pdf structures into a ReportLab generated document
    )format	PDFObject	pdfdocEnc)strTypesc                 T   [        [        [        5      (       a  [        O[        4nU[        [        4-   nU  Hm  n[        X!5      (       a  M  [        U5      S:w  a  [        S[        U5      -   5      e[        US   [        5      (       a  MU  [        S[        US   5      -   5      e   g )N   zTsequence elts must be strings/bytes/PDFPatternIfs or singletons containing strings: r   zCSingletons must contain strings/bytes or PDFObject instances only: )
isinstancer   tupler   PDFPatternIflen
ValueErrorascii)pattern_sequenceallowedTypesxs      N/var/www/html/env/lib/python3.13/site-packages/reportlab/pdfbase/pdfpattern.py_patternSequenceCheckr      s    )(E::8L9\"::L!))1vqy !wx}~  yA  "A  B  Bad8,, !fglmnopmqgr!rss     c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)
PDFPattern   r   c                 2    [        U5        Xl        X l        g)a  
Description of a kind of PDF object using a pattern.

Pattern sequence should contain strings, singletons of form [string] or
PDFPatternIf objects.
Strings are literal strings to be used in the object.
Singletons are names of keyword arguments to include.
PDFpatternIf objects allow some conditionality.
Keyword arguments can be non-instances which are substituted directly in string conversion,
or they can be object instances in which case they should be pdfdoc.* style
objects with a x.format(doc) method.
Keyword arguments may be set on initialization or subsequently using __setitem__, before format.
"constant object" instances can also be inserted in the patterns.
N)r   pattern	arguments)selfr   keywordargss      r   __init__PDFPattern.__init__   s     	./'$r   c                      X R                   U'   g Nr   )r   itemvalues      r   __setitem__PDFPattern.__setitem__%   s    $tr   c                      U R                   U   $ r    r!   )r   r"   s     r   __getitem__PDFPattern.__getitem__(   s    ~~d##r   c              #     #    U R                   nU R                  nU GHe  n[        U[        5      (       a  [	        U5      v   M(  [        U[
        5      (       a  UR                  U5      v   MR  [        U[        5      (       am  [        U R                  UR                  5      5      nU=(       a    US   nU R                  U(       a  UR                  OUR                  5       H  nUv   M	     M  US   nUR                  US 5      n	U	c  [        S[        U5      -  5      e[        U	[
        5      (       a  [        X5      v   GM*  [        U	[        5      (       a  [	        U	5      v   GMO  [	        [!        U	5      5      v   GMh     g 7f)Nr   z%s value not defined)r   _PDFPattern__documentr	   r   r   r   r   r   listevalcondthenPartelsePartgetr   r   str)
r   Lr   documentr   resultr-   znamer#   s
             r   r,   PDFPattern.eval+   s    NN	??A!H%%l"Ai((hhx((Al++dii/0+&)1::1::FAG G t!dD1=$%;eDk%IJJeI.. 00h//#E**#CJ//) s   FFc                 v    Xl          SR                  U R                  U R                  5      5      U ? $ ! U ? f = f)Nr   )r*   joinr,   r   )r   r3   s     r   r   PDFPattern.formatD   s0    "	 88DIIdll34s   )4 8c                     [         R                  U R                  5      nU R                  Ul        U R                  Ul        U$ r    )object__new__	__class__r   r   )r   cs     r   clonePDFPattern.cloneK   s/    NN4>>*LL	nnr   )
__documentr   r   N)__name__
__module____qualname____firstlineno____RefOnly__r   r$   r'   r,   r   r@   __static_attributes__ r   r   r   r      s%    K%&%$02 r   r   c                   &    \ rS rSrSr/ / 4S jrSrg)r   Q   zcond will be evaluated as [cond] in PDFpattern eval.
It should evaluate to a list with value 0/1 etc etc.
thenPart is a list to be evaluated if the cond evaulates true,
elsePart is the false sequence.
c                     [        U[        5      (       d  U/nXU4 H  n[        U5        M     Xl        X l        X0l        g r    )r	   r+   r   r-   r.   r/   )r   r-   r.   r/   r   s        r   r   PDFPatternIf.__init__W   s;    $t$$dVd)A!!$ *	  r   )r-   r/   r.   N)rC   rD   rE   rF   __doc__r   rH   rI   r   r   r   r   Q   s    
 %' !r   r   N)
rN   reportlab.pdfbase.pdfdocr   r   r   reportlab.lib.utilsr   r   r   r   rI   r   r   <module>rQ      s2   	 A A (t? ?B! !r   