
    MwgR                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZmZmZ d	d
lmZ  G d dee      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z eded ed!ed"ed#e d$iZ!e!jE                         D  ci c]  \  } }|| 
 c}} Z# G d% d&e      Z$y'c c}} w )(uD   Implementation of custom properties see § 22.3 in the specification    )warn)Strict)Serialisable)Sequence)AliasStringIntegerFloatDateTimeBool)
NestedText)CUSTPROPS_NS	VTYPES_NSCPROPS_FMTID   )NestedDateTimec                       e Zd ZdZy)NestedBoolTextzX
    Descriptor for handling nested elements with the value stored in the text part
    N)__name__
__module____qualname____doc__     P/var/www/horilla/myenv/lib/python3.12/site-packages/openpyxl/packaging/custom.pyr   r       s     	r   r   c                        e Zd ZdZdZdZ ed      Z ee	de
      Z eede
      Z eede
      Z ede
      Z eede
      Z ee	d      Z e       Z e       Zdd	edfd
Zed        Zd fd	Z xZS )_CustomDocumentPropertyz
    Low-level representation of a Custom Document Property.
    Not used directly
    Must always contain a child element, even if this is empty
    propertyNT
allow_none)expected_typer    	namespace)r    r"   )r!   r    r   c                     || _         || _        || _        d | _        || _        |j                         D ]  \  }}t        | ||       t        | d|       ! | j                  D ]  }||vst        | |d         y )N_typ)fmtidpidnamer$   
linkTargetitemssetattr__elements__)	selfr'   r&   r%   r(   kwkves	            r   __init__z _CustomDocumentProperty.__init__=   s     
		$HHJ 	%DAqD!QD&!$	% "" 	'A{a&	'r   c                     | j                   | j                   S | j                  D ]  }t        | |      |c S  | j                  yy )Nr(   )r$   r+   getattrr(   )r,   as     r   typez_CustomDocumentProperty.typeQ   sQ    99 99"" 	AtQ+	 ??& 'r   c                     t        | | j                  d       }|t        | | j                  d       t        |   d d d       S )N )tagnameidxr"   )r3   r$   r*   superto_tree)r,   r8   r9   r"   child	__class__s        r   r;   z_CustomDocumentProperty.to_tree\   s?    dii.=D$))R(wtFFr   NNN)r   r   r   r   r8   r$   r   r'   r   strr   lpwstrinti4floatr8r   filetimer   boolr(   r%   r	   r&   r   r1   r   r5   r;   __classcell__r=   s   @r   r   r   (   s     GDT"DcdiPF	#$)	LB	%DI	NBCHSDcd;JHE
)C # 	'(    G Gr   r   c                   Z     e Zd ZdZdZ eee      Z e	d      Z
ddZd Zd	 fd	Z xZS )
_CustomDocumentPropertyListzG
    Parses and seriliases property lists but is not used directly
    
Properties)r!   r"   r   c                     || _         y Nr   )r,   r   s     r   r1   z$_CustomDocumentPropertyList.__init__p   s	     r   c                 ,    t        | j                        S rM   )lenr   r,   s    r   __len__z#_CustomDocumentPropertyList.__len__t   s    4==!!r   c                     t        | j                  d      D ]  \  }}||_         t        |   |||      }|j                  dt               |S )N   xmlns)	enumerater   r&   r:   r;   setr   )r,   r8   r9   r"   ptreer=   s         r   r;   z#_CustomDocumentPropertyList.to_treex   sM    q1 	FCAE	wwY7,'r   )r   r>   )r   r   r   r   r8   r   r   r   r   r   customPropsr1   rR   r;   rG   rH   s   @r   rJ   rJ   d   s:     G&=VH
#K!" r   rJ   c                   ,    e Zd Z e       Zd Zd Zd Zy)_TypedPropertyc                      || _         || _        y rM   r'   value)r,   r'   r_   s      r   r1   z_TypedProperty.__init__   s     	
r   c                 j    | j                   |j                   k(  xr | j                  |j                  k(  S rM   r^   )r,   others     r   __eq__z_TypedProperty.__eq__   s'    yyEJJ&D4::+DDr   c                 f    | j                   j                   d| j                   d| j                   S )Nz, name=z, value=)r=   r   r'   r_   rQ   s    r   __repr__z_TypedProperty.__repr__   s,    ..))*'$))HTZZLQQr   N)r   r   r   r   r'   r1   rb   rd   r   r   r   r\   r\      s    8DERr   r\   c                       e Zd Z e       Zy)IntPropertyN)r   r   r   r	   r_   r   r   r   rf   rf      s	    IEr   rf   c                       e Zd Z e       Zy)FloatPropertyN)r   r   r   r
   r_   r   r   r   rh   rh      s	    GEr   rh   c                       e Zd Z ed      Zy)StringPropertyTr   Nr   r   r   r   r_   r   r   r   rj   rj      s    d#Er   rj   c                       e Zd Z e       Zy)DateTimePropertyN)r   r   r   r   r_   r   r   r   rm   rm      s	    JEr   rm   c                       e Zd Z e       Zy)BoolPropertyN)r   r   r   r   r_   r   r   r   ro   ro      s	    FEr   ro   c                       e Zd Z e       Zy)LinkPropertyNrk   r   r   r   rq   rq      s	    HEr   rq   r@   rB   rD   rE   rF   r(   c                   n    e Zd Z ee      Zd Zed        Zd Z	d Z
d Zed        Zd Zd	 Zd
 Zd Zy)CustomPropertyList)r!   c                     g | _         y rM   )propsrQ   s    r   r1   zCustomPropertyList.__init__   s	    
r   c                    t         j                  |      }g }|j                  D ]  }|j                  }t        j                  |d      }|st        d|j                          @t        ||      }|j                  }|t        }|j                  } ||j                  |      }	|j                  |	         |        }
||
_        |
S )z0
        Create list from OOXML element
        NzUnknown type for r^   )rJ   	from_treer   r5   XML_MAPPINGgetr   r'   r3   r(   rq   appendru   )clsrY   	prop_listru   propattrtypr_   linknew_propnew_prop_lists              r   rw   zCustomPropertyList.from_tree   s    
 099$?	&& 	#D99D//$-C(45D$'E??D"		7HLL"	#  #r   c                     |j                   | j                  v rt        d|j                    d      | j                  j	                  |       y )NProperty with name z already exists)r'   names
ValueErrorru   rz   )r,   r}   s     r   rz   zCustomPropertyList.append   s=    99

"2499+_MNN

$r   c                 P   g }| j                   D ]z  }t        j                  |j                  d       }|st	        d      t        dd|j                  i||j                  i}t        |t              rd|_
        |j                  |       | t        |      }|j                         S )NzUnknown adapter for {p}r'   r@   rN   r   )ru   CLASS_MAPPINGry   r=   	TypeErrorr   r'   r_   
isinstancerq   r$   rz   rJ   r;   )r,   ru   rX   r~   npr|   s         r   r;   zCustomPropertyList.to_tree   s     	A $$Q[[$7D 9::(GaffGaggGB!\*"LL	 0?	  ""r   c                 ,    t        | j                        S rM   )rP   ru   rQ   s    r   rR   zCustomPropertyList.__len__   s    4::r   c                 T    | j                   D cg c]  }|j                   c}S c c}w )zList of property names)ru   r'   )r,   rX   s     r   r   zCustomPropertyList.names  s      !%

+1+++s   %c                 h    | j                   D ]  }|j                  |k(  s|c S  t        d| d      )z&
        Get property by name
        r   
 not found)ru   r'   KeyError)r,   r'   rX   s      r   __getitem__zCustomPropertyList.__getitem__  s>      	Avv~	 ,TF*=>>r   c                     t        | j                        D ]1  \  }}|j                  |k(  s| j                  j                  |        y t	        d| d      )z*
        Delete a propery by name
        Nr   r   )rV   ru   r'   popr   )r,   r'   r9   rX   s       r   __delitem__zCustomPropertyList.__delitem__  sU      

+ 	FCvv~

s#	 ,TF*=>>r   c                 L    | j                   j                   d| j                   S )Nz containing )r=   r   ru   rQ   s    r   rd   zCustomPropertyList.__repr__  s"    ..))*,tzzlCCr   c                 ,    t        | j                        S rM   )iterru   rQ   s    r   __iter__zCustomPropertyList.__iter__   s    DJJr   N)r   r   r   r   r\   ru   r1   classmethodrw   rz   r;   rR   r   r   r   r   rd   r   r   r   r   rs   rs      s_     >2E  8 #" , ,
??D r   rs   N)%r   warningsr   openpyxl.descriptorsr   !openpyxl.descriptors.serialisabler   openpyxl.descriptors.sequencer   r   r   r	   r
   r   r   openpyxl.descriptors.nestedr   openpyxl.xml.constantsr   r   r   corer   r   r   rJ   r\   rf   rh   rj   rm   ro   rq   r   r)   rx   rs   )r.   r/   s   00r   <module>r      s   K  ' : 2   !	T: 	9Gl 9Gx, :RV R&. 
N 
$^ $
~ 
> 
>  H4j&, ,1134sqqs4b  b  5s   C.