
    Q?h                         S r SrSSKJrJr  SSKJr  SSKJr   " S S5      r	 " S S	5      r
 " S
 S\5      rS rSS jrS rS rSS jrg)z3.3.0a  Framework for objects whose assignments are checked. Used by graphics.

We developed reportlab/graphics prior to Python 2 and metaclasses. For the
graphics, we wanted to be able to declare the attributes of a class, check
them on assignment, and convert from string arguments.  Examples of
attrmap-based objects can be found in reportlab/graphics/shapes.  It lets
us defined structures like the one below, which are seen more modern form in
Django models and other frameworks.

We'll probably replace this one day soon, hopefully with no impact on client
code.

class Rect(SolidShape):
    """Rectangle, possibly with rounded corners."""

    _attrMap = AttrMap(BASE=SolidShape,
        x = AttrMapValue(isNumber),
        y = AttrMapValue(isNumber),
        width = AttrMapValue(isNumber),
        height = AttrMapValue(isNumber),
        rx = AttrMapValue(isNumber),
        ry = AttrMapValue(isNumber),
        )


    )
isAnythingDerivedValue)isSeq)	rl_configc                   $    \ rS rSrSrS rS rSrg)CallableValue#   z(a class to allow callable initial valuesc                 (    Xl         X l        X0l        g Nfuncargskw)selfr   r   r   s       G/var/www/html/env/lib/python3.13/site-packages/reportlab/lib/attrmap.py__init__CallableValue.__init__%   s    		    c                 N    U R                   " U R                  0 U R                  D6$ r   r   )r   s    r   __call__CallableValue.__call__+   s    yy$)).dgg..r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r   #   s    2/r   r   c                   .    \ rS rSrSrSS jrS rS rSrg)	AttrMapValue.   z,Simple multi-value holder for attribute mapsNc                     U=(       d    [         U l        X l        X0l        X@l        UR                  5        H  u  pg[        XU5        M     g r   )r   validatedesc_initial_advancedUsageitemssetattr)r   r#   r$   initialadvancedUsager   kvs           r   r   AttrMapValue.__init__0   s:     .J	+88:CAD1 r   c                     US:X  a;  [        U R                  [        5      (       a  U R                  5       $ U R                  $ US:X  a  g[        U5      e)Nr)   hiddenr   )
isinstancer%   r   AttributeError)r   names     r   __getattr__AttrMapValue.__getattr__8   sD    ?$--66t}}8N== 8^T""r   c                     SSR                  U R                  R                  5        Vs/ s H  nSU-  PM
     sn5      -  $ s  snf )NzAttrMapValue(%s)z, z%s=%r)join__dict__r'   )r   is     r   __repr__AttrMapValue.__repr__A   s;    !DIIDMMDWDWDY.ZDYqw{DY.Z$[[[.Zs   A
)r&   r%   r$   r#   )NNNr   )	r   r   r   r   r   r   r3   r9   r   r   r   r   r    r    .   s    6#\r   r    c                   4    \ rS rSrS/ 4S jrS r/ 4S jrSrg)AttrMapD   Nc                 p   0 nU(       av  [        U[        5      (       a  UnO^[        U5      (       d  U4nU HE  n[        USU 5      nX`La  U(       a  UR	                  U5        M.  M0  [        S[        U5      -  5      e   [        R                  X5        U R                  U5        U R	                  U5        g )N_attrMapzBASE=%s has wrong kind of value)
r0   r<   r   getattrupdate
ValueErrorasciidictr   remove)r   BASEUNWANTEDr   dataBams          r   r   AttrMap.__init__E   s    $w''T{{D7DA :d3B~t{{22()JUSTX)UVV  	d HBr   c                 >    U H  n X	 M     g ! [          a     M  f = fr   )KeyError)r   unwantedr+   s      r   rE   AttrMap.removeW   s*    AG   s   
c                 :    [        XS9nUR                  U5        U$ )N)rF   rG   )r<   rA   )r   rG   r   cs       r   cloneAttrMap.clone^   s    0	r   r   )r   r   r   r   r   rE   rR   r   r   r   r   r<   r<   D   s     $  r   r<   c                 T   [         R                  (       Ga  U R                  nU(       Ga  US   S:w  a  [        U[        5      (       a  OX;   aH  X1   R
                  n U" U5      nU(       d)  [        SU< SU SU R                  R                   35      eO[        U R                  US
5      n[        U[        5      (       aB  [        USS
5      nU(       a	  U" X5        g
[        U R                  R                   SU S35      e[        SU< SU R                  R                  < 35      e[        U R                  US
5      n[        U[        5      (       aB  [        USS
5      nU(       a	  U" X5        g
[        U R                  R                   SU S35      eUS:X  a6  U R                  R                  5         U R                  R                  U5        g
X R                  U'   g
! [         a8  nUR                  U R                  R                   SU SU SU< S	35      UeS
nAff = f)z validate setattr(obj,name,value)r   _zIllegal assignment of z to z
 in class . ()Nfsetz has no setterzIllegal attribute 'z' in class r7   )r   shapeCheckingr?   r0   r   r#   r1   	__class__r   	Exceptionr@   propertyr7   clearrA   )	objr2   valueaMapr#   reproprZ   s	            r   validateSetattrrf   c   s   ||DGcM %..:..} A ,/EeYdSWRXXbcfcpcpcycybz-{||  s}}T$7d8,,"4t4DS,0F0F/Gqn-]^^(QUWZWdWdWmWm)noo3==d+D$x  tF4(O CMM$:$:#;1TF.!QRR	z	E""T7 ! g++)?)?(@$q
RSTYS\\]&^_effgs   G% %
H'/3H""H'c                     U R                   n[        U R                  SS5      nU(       a  X2L a  UR                  5       U4$ US4$ X2L a  UR                  5       U l         gg)zclone obj._attrMap if requiredr?   N)r?   r@   r\   rR   )r`   retAoAs       r   _privateAttrMaprk      sU    A	z$	/B
7779b= d7N7779CL r   c                 ~    UR                  S5      n[        U5      S:X  a  gUSS  H  n[        X5      n M     XS   4$ )zPLocate the object src.P for P a string, return parent and name of attribute
    rV   r   )NN)splitlenr@   )srcPps      r   _findObjectAndAttrrs      sD     	
A
1v{1RA#/C bEzr   c           
          [        U S5      (       dX  U R                  nSS KnUR                  UR                  U4UR
                  -   / [        U SS 5      [        4S jS.5      U l        g g )N__attrproxy__r   __setattr__c                     U" XX#5      $ r   r   )r   r+   r,   osahooks        r   <lambda>!hook__setattr__.<locals>.<lambda>   s    Y]^befYkr   )ru   rv   )hasattrr\   newclassobjr   	__bases__r@   ry   )r`   Cr}   s      r   hook__setattr__r      s_    3''MMll1::qd1;;.>.5c-.MSWkmn (r   Nc                    [        U S5      (       d   S5       e[        U S5      u  pg[        U5      (       d  U4n/ n/ n	U H?  n
[        U
5      (       a	  U
S   U
SS p[        X
5      u  pU(       d  M2  [	        USS5      nMA     g)z6
Add a proxy attribute 'name' to src with targets dst
r?   zsrc object has no _attrMap   r   N)r|   rk   r   rs   r@   )rp   r2   r#   r$   r)   dstri   rj   DDVdrd   r`   attrdAs                  r   addProxyAttributer      s    
 3z""@$@@"C"EA::STs
A	B88Q412q&s-	3Z-B r   )r   )NNNN)__version__r   reportlab.lib.validatorsr   r   reportlab.lib.utilsr   	reportlabr   r   r    rD   r<   rf   rk   rs   r   r   r   r   r   <module>r      s[    	4 > % 	/ 	/\ \,d >)#V%	n.r   