o
    gs                     @   s   d dl Z d dlZd dlmZ d dlmZ ejr#d dlmZ d dl	m
Z
 ddgZG dd dZd	d
 ZG dd deZG dd dZdd ZdS )    N)OrderedDict)PrettyPrinter)Element)ComplexType	AnyObjectCompoundValuec                   @   s@   e Zd ZdZdd Zdd Zdd Zedd	 Zed
d Z	dS )r   z[Create an any object

    :param xsd_object: the xsd type
    :param value: The value

    c                 C   s   || _ || _d S N)xsd_objvalue)self
xsd_objectr
    r   N/home/ubuntu/webapp/venv/lib/python3.10/site-packages/zeep/xsd/valueobjects.py__init__   s   
zAnyObject.__init__c                 C   s   d| j j| j| jf S )Nz<%s(type=%r, value=%r)>)	__class____name__xsd_elmr
   r   r   r   r   __repr__   s
   zAnyObject.__repr__c                 C   s   t | | jt| jS r   )typer   copydeepcopyr
   )r   memor   r   r   __deepcopy__!   s   zAnyObject.__deepcopy__c                 C      | j S r   r	   r   r   r   r   xsd_type$      zAnyObject.xsd_typec                 C   r   r   r   r   r   r   r   r   (   r   zAnyObject.xsd_elmN)
r   
__module____qualname____doc__r   r   r   propertyr   r   r   r   r   r   r      s    
c                 C   s$   t | tfddd}| }||_|S )zZHelper function to recreate pickled CompoundValue.

    See CompoundValue.__reduce__

    Nzeep.objects	_xsd_typer   )r   r   
__values__)namevaluesclsobjr   r   r   _unpickle_compound_value-   s   r*   c                       s:   e Zd Zejr	dZ fddZdd Zedd Z	  Z
S )
ArrayValueNc                    s   t  | d S r   )superr   )r   itemsr   r   r   r   ?   s   zArrayValue.__init__c                 C   s&   t | jjtf| jdd}|t| S )Nr"   r#   )r   r   r   r   r$   list)r   	anon_typer   r   r   as_value_objectB   s   
zArrayValue.as_value_objectc                 C   s   t t|j }| |pg S r   )nextiterr%   r'   )r(   r)   r-   r   r   r   from_value_objectJ   s   zArrayValue.from_value_object)r   r   r   typingTYPE_CHECKINGr$   r   r1   classmethodr4   __classcell__r   r   r.   r   r+   ;   s    r+   c                       s   e Zd ZU dZded< ded< dd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Z fddZ fddZd d! Zd"d# Z  ZS )$r   z8Represents a data object for a specific xsd:complexType.r   r$   r   _xsd_elmc                 O   s   t  }| jd u r
d S | jjD ]\}}|j}t|tr || q|||< q| jjD ]	\}}|j||< q)t| j||}	|		 D ]\}
}|||
< q>|| _
d S r   )r   r$   elements_nesteddefault_value
isinstancedictupdate
attributes_process_signaturer-   r%   )r   argskwargsr'   container_name	container
elm_valuesattribute_name	attributer-   keyr
   r   r   r   r   V   s   




zCompoundValue.__init__c                 C   s   t | jj| jffS r   )r*   r   r   r%   r   r   r   r   
__reduce__o   s   zCompoundValue.__reduce__c                 C      | j |S r   )r%   __contains__r   rH   r   r   r   rK   r      zCompoundValue.__contains__c                    s,   | j  j krdS  fdd D }|| jkS )NFc                    s   i | ]}| | qS r   r   ).0rH   otherr   r   
<dictcomp>y   s    z(CompoundValue.__eq__.<locals>.<dictcomp>)r   r%   )r   rP   other_valuesr   rO   r   __eq__u   s   
zCompoundValue.__eq__c                 C   
   | j  S r   )r%   __len__r   r   r   r   rU   |      
zCompoundValue.__len__c                 C   rT   r   )r%   __iter__r   r   r   r   rW      rV   zCompoundValue.__iter__c                 C   s   t | j S r   )r/   r%   keysr   r   r   r   __dir__      zCompoundValue.__dir__c                 C   s   t  | jS r   )r   pformatr%   r   r   r   r   r      rZ   zCompoundValue.__repr__c                 C   rJ   r   )r%   __delitem__rL   r   r   r   r\      rM   zCompoundValue.__delitem__c                 C   s
   | j | S r   r%   rL   r   r   r   __getitem__   rV   zCompoundValue.__getitem__c                 C   s   || j |< d S r   r]   r   rH   r
   r   r   r   __setitem__   rZ   zCompoundValue.__setitem__c                    s.   | ds	|dv rt ||S || j|< d S )N__r$   r9   )
startswithr,   __setattr__r%   r_   r.   r   r   rd      s   zCompoundValue.__setattr__c                    sN   | ds	|dv rt |S z| j| W S  ty&   td| jj|f w )Nra   rb   z!%s instance has no attribute '%s')rc   r,   __getattribute__r%   KeyErrorAttributeErrorr   r   rL   r.   r   r   re      s   zCompoundValue.__getattribute__c                 C   sD   t |  }t| j|_| j D ]\}}|dkrt||| q|S )Nr%   )r   r   r   r%   __dict__r-   setattr)r   r   newattrr
   r   r   r   r      s   
zCompoundValue.__deepcopy__c                 C   r   r   r]   r   r   r   r   __json__   s   zCompoundValue.__json__)r   r   r   r    __annotations__r   rI   rK   rS   rU   rW   rY   r   r\   r^   r`   rd   re   r   rl   r8   r   r   r.   r   r   P   s&   
 
c                 C   s  t  }|rOt|}t|}d}| jD ]\}}|||\}}}|s# n|| q| jD ]\}	}
||kr6 n|| ||	< |d7 }q,||krOtdt||f t|	 }| jD ]+\}}|j
rg||||}n||d|}|dur| D ]\}}||vr|||< qvqX|r| jD ]\}	}
|	|v r||	 ||	 ||	< qd|v r|d r|d |d< |d |rtd| jpdtt|| jdd	f |S )
ae  Return a dict with the args/kwargs mapped to the field name.

    Special handling is done for Choice elements since we need to record which
    element the user intends to use.

    :param fields: List of tuples (name, element)
    :type fields: list
    :param args: arg tuples
    :type args: tuple
    :param kwargs: kwargs
    :type kwargs: dict


    r      z;__init__() takes at most %s positional arguments (%s given)N_raw_elementsz;%s() got an unexpected keyword argument %r. Signature: `%s`r   F)
standalone)r   r/   lenr:   
parse_argsr>   r?   	TypeErrorsetrX   accepts_multipleparse_kwargsr-   removeqnamer2   r3   	signature)r   rA   rB   resultnum_argsindexelement_nameelementr'   rF   rG   available_kwargsrH   r
   r   r   r   r@      sd   





	r@   )r   r5   collectionsr   zeep.xsd.printerr   r6   zeep.xsd.elementsr   zeep.xsd.typesr   __all__r   r*   r/   r+   r   r@   r   r   r   r   <module>   s    \