
    fhR                        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!d% e!"                                D             Z# G d& d'e          Z$d(S ))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dS )NestedBoolTextzX
    Descriptor for handling nested elements with the value stored in the text part
    N)__name__
__module____qualname____doc__     P/var/www/histauto/venv/lib/python3.11/site-packages/openpyxl/packaging/custom.pyr   r       s          	Dr   r   c                   6    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 | _        || _        |                                D ]'\  }}t          | ||           t          | d|           (| j        D ]}||vrt          | |d            d S )N_typ)fmtidpidnamer$   
linkTargetitemssetattr__elements__)	selfr'   r&   r%   r(   kwkves	            r   __init__z _CustomDocumentProperty.__init__=   s     
		$HHJJ 	% 	%DAqD!QD&!$$$$" 	' 	'A{{a&&&	' 	'r   c                 p    | j         | j         S | j        D ]}t          | |          |c S | j        dS d S )Nr(   )r$   r+   getattrr(   )r,   as     r   typez_CustomDocumentProperty.typeQ   sW    9 9" 	 	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\   sK    di..=D$)R(((wwtF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   (   sB         GD6T"""DZcdiPPPF	#$)	L	L	LB	%DI	N	N	NB~CCCH>SSSDcd;;;JFHHE
'))C # 	' ' ' '(     X G G G G G G G G G Gr   r   c                   f     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   r   c                     || _         d S 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   Nc                     t          | j        d          D ]\  }}||_        t                                          |||          }|                    dt                     |S )N   xmlns)	enumerater   r&   r:   r;   setr   )r,   r8   r9   r"   ptreer=   s         r   r;   z#_CustomDocumentPropertyList.to_treex   s]    q11 	 	FCAEEwwwY7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x&=VVVH%
##K! ! ! !" " "         r   rJ   c                   4    e Zd Z e            Zd Zd Zd ZdS )_TypedPropertyc                 "    || _         || _        d S rM   r'   value)r,   r'   r_   s      r   r1   z_TypedProperty.__init__   s     	


r   c                 B    | j         |j         k    o| j        |j        k    S rM   r^   )r,   others     r   __eq__z_TypedProperty.__eq__   s    yEJ&D4:+DDr   c                 >    | j         j         d| j         d| j         S )Nz, name=z, value=)r=   r   r'   r_   rQ   s    r   __repr__z_TypedProperty.__repr__   s'    .)QQ$)QQTZQQQr   N)r   r   r   r   r'   r1   rb   rd   r   r   r   r\   r\      sT        688D  E E ER R R R Rr   r\   c                   "    e Zd Z e            ZdS )IntPropertyN)r   r   r   r	   r_   r   r   r   rf   rf      s        GIIEEEr   rf   c                   "    e Zd Z e            ZdS )FloatPropertyN)r   r   r   r
   r_   r   r   r   rh   rh      s        EGGEEEr   rh   c                   &    e Zd Z ed          ZdS )StringPropertyTr   Nr   r   r   r   r_   r   r   r   rj   rj      s         Fd###EEEr   rj   c                   "    e Zd Z e            ZdS )DateTimePropertyN)r   r   r   r   r_   r   r   r   rm   rm      s        HJJEEEr   rm   c                   "    e Zd Z e            ZdS )BoolPropertyN)r   r   r   r   r_   r   r   r   ro   ro      s        DFFEEEr   ro   c                   "    e Zd Z e            ZdS )LinkPropertyNrk   r   r   r   rq   rq      s        FHHEEEr   rq   r@   rB   rD   rE   rF   r(   c                     i | ]\  }}||	S r   r   ).0r.   r/   s      r   
<dictcomp>rt      s    444sqq444r   c                       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dS )CustomPropertyList)r!   c                     g | _         d S rM   propsrQ   s    r   r1   zCustomPropertyList.__init__   s    


r   c                    t                               |          }g }|j        D ]}|j        }t                              |d          }|st          d|j                    >t          ||          }|j	        }|t          }|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   appendry   )clsrY   	prop_listry   propattrtypr_   linknew_propnew_prop_lists              r   r{   zCustomPropertyList.from_tree   s    
 099$??	& 	# 	#D9D//$--C 444555D$''E?D"s	777HLL""""#r   c                     |j         | j        v rt          d|j          d          | j                            |           d S )NProperty with name z already exists)r'   names
ValueErrorry   r~   )r,   r   s     r   r~   zCustomPropertyList.append   sI    9
""M49MMMNNN
$r   c                 Z   g }| j         D ]~}t                              |j        d           }|st	          d          t          dd|j        i||j        i}t          |t                    rd|_
        |                    |           t          |          }|                                S )NzUnknown adapter for {p}r'   r@   rN   r   )ry   CLASS_MAPPINGr}   r=   	TypeErrorr   r'   r_   
isinstancerq   r$   r~   rJ   r;   )r,   ry   rX   r   npr   s         r   r;   zCustomPropertyList.to_tree   s     	 	A $$Q[$77D ; 9:::(GGafGagGGB!\** #"LL/???	  """r   c                 *    t          | j                  S rM   )rP   ry   rQ   s    r   rR   zCustomPropertyList.__len__   s    4:r   c                 $    d | j         D             S )zList of property namesc                     g | ]	}|j         
S r   )r'   )rs   rX   s     r   
<listcomp>z,CustomPropertyList.names.<locals>.<listcomp>  s    +++1+++r   rx   rQ   s    r   r   zCustomPropertyList.names  s     ,+
++++r   c                 Z    | j         D ]}|j        |k    r|c S t          d| d          )z&
        Get property by name
        r   
 not found)ry   r'   KeyError)r,   r'   rX   s      r   __getitem__zCustomPropertyList.__getitem__  sH      	 	Av~~ =T===>>>r   c                     t          | j                  D ]-\  }}|j        |k    r| j                            |            dS .t	          d| d          )z*
        Delete a propery by name
        Nr   r   )rV   ry   r'   popr   )r,   r'   r9   rX   s       r   __delitem__zCustomPropertyList.__delitem__  sh      
++ 	 	FCv~~
s###  =T===>>>r   c                 .    | j         j         d| j         S )Nz containing )r=   r   ry   rQ   s    r   rd   zCustomPropertyList.__repr__  s    .)CCtzCCCr   c                 *    t          | j                  S rM   )iterry   rQ   s    r   __iter__zCustomPropertyList.__iter__   s    DJr   N)r   r   r   r   r\   ry   r1   classmethodr{   r~   r;   rR   r   r   r   r   rd   r   r   r   r   rv   rv      s         H>222E     [8     # # #"   , , X,
? ? ?? ? ?D D D         r   rv   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)   r|   rv   r   r   r   <module>r      sI   K J       ' ' ' ' ' ' : : : : : : 2 2 2 2 2 2                              !          	 	 	 	 	T: 	 	 	9G 9G 9G 9G 9Gl 9G 9G 9Gx    ,   :R R R R RV R R R&    .   
    N   
$ $ $ $ $^ $ $ $
    ~   
    >   
    >    H4j&, 54m1133444b  b  b  b  b  b  b  b  b  b r   