o
    i@                     @   s  d Z ddlZedZe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 dd
lmZ ddlmZ ddlmZ ddlmZmZ ddlmZmZ ddlmZ ddlmZmZmZ ddlm Z m!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( ddlm)Z) ddlm*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlmAZA eAjBreCeDfZEneCeFfZEe ddiZGe d ZHd!d" ZId#d$ ZJG d%d& d&e#ZKG d'd( d(e@ZLG d)d* d*eLZMdS )+a  The ``spyne.protocol.xml`` module contains an xml-based protocol that
serializes python objects to xml using Xml Schema conventions.

Logs valid documents to ``'spyne.protocol.xml'`` and invalid documents to
``spyne.protocol.xml.invalid``. Use the usual ``logging.getLogger()`` and
friends to configure how these get logged.

Warning! You can get a lot of crap in the 'invalid' logger. You're not advised
to turn it on for a production system.
    Nzspyne.protocol.xmlzspyne.protocol.xml.invalid)isgenerator)defaultdict)etree)html)E)XMLSyntaxError)	XMLParser)BODY_STYLE_WRAPPED)Break	coroutine)	text_typestring_types)cdict)etree_to_dictdict_to_etreeroot_dict_to_etree)XSINS_SOAP11_ENC)Fault)ValidationError)LIGHT_GREEN)	LIGHT_RED)	END_COLOR)NS_SOAP11_ENV)PREFMAP
DEFAULT_NS)Any	ModelBaseArrayIterableComplexModelBaseAnyHtmlAnyXmlAnyDictUnicodePushBaseFile	ByteArrayXmlDataXmlAttribute)BINARY_ENCODING_BASE64)EnumBase)ProtocolBase)sixniltruetypec                 C   s&   t | dr| | d S | | d S )Nappend)hasattrr1   write)parent	child_elt r6   R/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/protocol/xml.py_appendS   s   
r8   c                 C   s   | d ur
d| |f }|S N{%s}%sr6   )nsnamer6   r6   r7   _gen_tagnameZ   s   r=   c                       s$   e Zd ZdZdZ fddZ  ZS )SchemaValidationErrorzFRaised when the input stream could not be validated by the Xml Schema.zClient.SchemaValidationErrorc                    s   t t| | j| d S N)superr>   __init__CODE)selffaultstring	__class__r6   r7   rA   e   s   zSchemaValidationError.__init__)__name__
__module____qualname____doc__rB   rA   __classcell__r6   r6   rE   r7   r>   `   s    r>   c                   @   s   e Zd ZdddZdd ZdS )
SubXmlBaseNc                 C   s   |  |||||S r?   )	to_parent)rC   ctxclsinstr4   r;   r<   r6   r6   r7   subserializej   s   zSubXmlBase.subserializec                 O   s   t  )a  Serializes inst to an Element instance and appends it to the 'parent'.

        :param self:  The protocol that will be used to serialize the given
            value.
        :param cls:   The type of the value that's going to determine how to
            pack the given value.
        :param inst: The value to be set for the 'text' element of the newly
            created SubElement
        :param parent: The parent Element to which the new child will be
            appended.
        :param ns:   The target namespace of the new SubElement, used with
            'name' to set the tag.
        :param name:  The tag name of the new SubElement, 'retval' by default.
        )NotImplementedError)rC   rN   rO   rP   r4   r;   argskwargsr6   r6   r7   rM   m   s   zSubXmlBase.to_parent)NN)rG   rH   rI   rQ   rM   r6   r6   r6   r7   rL   i   s    
rL   c                       s  e Zd ZdZedefi ZdZeZ	e
ejZed ee ZeZeZ																			d] fdd		Zd
d Zdd Zdd Zdd Zd^ddZdd Zdd Zdd Zdd Zdd Zd^ddZed^d d!Z d_d"d#Z!d`d%d&Z"d`d'd(Z#d`d)d*Z$d+d, Z%	d_d-d.Z&d/d0 Z'ed1d2 Z(ed3d4 Z)		dad5d6Z*d7d8 Z+d9d: Z,d;d< Z-d`d=d>Z.d?d@ Z/dAdB Z0dCdD Z1dEdF Z2dGdH Z3dIdJ Z4dKdL Z5dMdN Z6dOdP Z7dQdR Z8dSdT Z9dUdV Z:dWdX Z;dYdZ Z<d[d\ Z=  Z>S )bXmlDocumenta  The Xml input and output protocol, using the information from the Xml
    Schema generated by Spyne types.

    See the following material for more (much much more!) information.

    * http://www.w3.org/TR/xmlschema-0/
    * http://www.w3.org/TR/xmlschema-1/
    * http://www.w3.org/TR/xmlschema-2/

    Receiving Xml from untrusted sources is a dodgy security dance as the Xml
    attack surface is /huge/.

    Spyne's ```lxml.etree.XMLParser``` instance has ```resolve_pis```,
    ```load_dtd```, ```resolve_entities```, ```dtd_validation```,
    ```huge_tree``` Defaults to ``False``

    Having ```resolve_entities``` disabled will prevent the 'lxml' validation
    for documents with custom xml entities defined in the DTD. See the example
    in examples/xml/validation_error to play with the settings that work best
    for you. Please note that enabling ```resolve_entities``` is a security
    hazard that can lead to disclosure of sensitive information.

    See https://pypi.python.org/pypi/defusedxml for a pragmatic overview of
    Xml security in Python world.

    :param app: The owner application instance.

    :param validator: One of (None, 'soft', 'lxml', 'schema',
        ProtocolBase.SOFT_VALIDATION, XmlDocument.SCHEMA_VALIDATION).
        Both ``'lxml'`` and ``'schema'`` values are equivalent to
        ``XmlDocument.SCHEMA_VALIDATION``.

        Defaults to ``None``.

    :param replace_null_with_default: If ``False``, does not replace incoming
        explicit null values with denoted default values. This is against Xml
        Schema standard but consistent with other Spyne protocol
        implementations. Set this to False if you want cross-protocol
        compatibility.

        Defaults to ``True``.

        Relevant quote from xml schema primer
        (http://www.w3.org/TR/xmlschema-0/):

        ..
            When a value is present and is null The schema processor treats
            defaulted elements slightly differently. When an element is declared
            with a default value, the value of the element is whatever value
            appears as the element's content in the instance document; if the
            element appears without any content, the schema processor provides
            the element with a value equal to that of the default attribute.
            However, if the element does not appear in the instance document,
            the schema processor does not provide the element at all. In
            summary, the differences between element and attribute defaults can
            be stated as: Default attribute values apply when attributes are
            missing, and default element values apply when elements are empty.

    :param xml_declaration: Whether to add xml_declaration to the responses

        Defaults to ``True``.

    :param cleanup_namespaces: Whether to add clean up namespace declarations
        in the response document.

        Defaults to ``True``.

    :param encoding: The suggested string encoding for the returned xml
        documents. The transport can override this.

        Defaults to ``None``.

    :param pretty_print: When ``True``, returns the document in a pretty-printed
        format.

        Defaults to ``False``.

    :param parse_xsi_type: Set to ``False`` to disable parsing of ``xsi:type``
        attribute, effectively disabling polymorphism.

        Defaults to ``True``.

    The following are passed straight to the ``XMLParser()`` instance from
    lxml. Docs are also plagiarized from the lxml documentation. Please note
    that some of the defaults are different to make parsing safer by default.

    :param attribute_defaults: read the DTD (if referenced by the document) and
        add the default attributes from it.

        Defaults to ``False``

    :param dtd_validation: validate while parsing (if a DTD was referenced).

        Defaults to ``False``

    :param load_dtd: load and parse the DTD while parsing (no validation is
        performed).

        Defaults to ``False``.

    :param no_network: prevent network access when looking up external
        documents.

        Defaults to ``True``.

    :param ns_clean: try to clean up redundant namespace declarations.
        Please note that this is for incoming documents.
        See ``cleanup_namespaces`` parameter for output documents.

        Defaults to ``False``.

    :param recover: try hard to parse through broken Xml.

        Defaults to ``False``.

    :param remove_blank_text: discard blank text nodes between tags, also known
        as ignorable whitespace. This is best used together with a DTD or schema
        (which tells data and noise apart), otherwise a heuristic will be
        applied.

        Defaults to ``False``.

    :param remove_pis: When ``True`` xml parser discards processing
        instructions.

        Defaults to ``True``.

    :param strip_cdata: replace CDATA sections by normal text content.

        Defaults to ``True``

    :param resolve_entities: replace entities by their text value.

        Defaults to ``False``.

    :param huge_tree: disable security restrictions and support very deep trees
        and very long text content. (only affects libxml2 2.7+)

        Defaults to ``False``.

    :param compact: use compact storage for short text content.

        Defaults to ``True``.

    Schemaztext/xmlxmlNTFc                    s$  t t| j|||d d | _|| _|| _|| _|d u rd| _n|| _|| _|| _	|| _
tt| jt| jt| jt| jt| jt| jt| jt| jt| jt| jt | j!t"| j#i| _$tt| j%t| j&t| j&t'| j(t| j)t| j*t| j+t| j,t-| j.t/| j0t| j1t| j2i| _3t4||	|
||||d||||||d| _5d S )N)binary_encodingUTF-8T)attribute_defaultsdtd_validationload_dtd
no_networkns_cleanrecoverremove_blank_textremove_comments
remove_pisstrip_cdataresolve_entities	huge_treecompactencoding)6r@   rU   rA   validation_schemaxml_declarationcleanup_namespacesreplace_null_with_defaultrg   polymorphicpretty_printparse_xsi_typer   r   any_to_parentr   fault_to_parentr+   enum_to_parentr"   any_xml_to_parentr(   xmldata_to_parentr#   any_dict_to_parentr!   any_html_to_parentr   modelbase_to_parentr'   byte_array_to_parentr    complex_to_parentr)   xmlattribute_to_parentr>   !schema_validation_error_to_parentserialization_handlershtml_from_elementxml_from_elementr   array_from_elementfault_from_elementdict_from_elementenum_from_elementbase_from_elementr$   unicode_from_elementr   iterable_from_elementbyte_array_from_elementcomplex_from_elementdeserialization_handlersdictparser_kwargs)rC   app	validatorrk   ri   rj   rg   rm   rZ   r[   r\   r]   r^   r_   r`   rb   rc   rd   re   rf   rX   rn   rl   rE   r6   r7   rA     sr   zXmlDocument.__init__c                 C   s\   |dv s	|| j u r| j| _| j | _n|dks|| ju r | j| _n	|d u r%nt|d | _d S )N)lxmlschemasoft)SCHEMA_VALIDATION_XmlDocument__validate_lxmlvalidate_documentr   SOFT_VALIDATION
ValueErrorrh   )rC   r   r6   r6   r7   set_validators  s   



zXmlDocument.set_validatorc                 C   s   || j | jfv sJ |td t }z8| |j || j u r%td t }ntd t }W tjt	j
krItd||jf  ttj|jdd dS dS tjt	j
krgtd||jf  ttj|jdd w w )zZSets ctx.method_request_string and calls :func:`generate_contexts`
        for validation.zError:zMethod request string:z	Response:%s %sT)rm   N)REQUESTRESPONSEr   r   r   in_body_docr   loggerlevelloggingDEBUGdebugmethod_request_stringr   tostringin_document)rC   rN   messageline_headerr6   r6   r7   validate_body  s   
zXmlDocument.validate_bodyc                 C   sN   t | | d | _| j| ju r#|d ur%| jjjj}|	  |j| _d S d S d S r?   )
r,   set_apprh   r   r   r   	interfacedocs
xml_schemabuild_validation_schema)rC   valuer   r6   r6   r7   r     s   zXmlDocument.set_appc                 C   sD   | j |}td|  |dkr t| j jj}t|ddd S )NzValidated ? %rFasciixmlcharrefreplace)	rh   validater   r   r   	error_log
last_errorr>   encode)rC   payloadret
error_textr6   r6   r7   __validate_lxml  s   zXmlDocument.__validate_lxmlc              
   C   s   d |j}z.ztj|tdi | jd|_W W dS  ty4   t	d t|
|| j|_Y W dS w  tyN } ztd|| tdt|d}~ww )z^Uses the iterable of string fragments in ``ctx.in_string`` to set
        ``ctx.in_document``.    )parserzbValueError: Deserializing from unicode strings with encoding declaration is not supported by lxml.z%r in string %rzClient.XMLSyntaxErrorNr6   )join	in_stringr   
fromstringr   r   r   r   r   r   decoder   r   logger_invaliderrorr   str)rC   rN   charsetstringer6   r6   r7   create_in_document  s"   
zXmlDocument.create_in_documentc                 C   s<   || j | jfv s
J d |_|j|_|jj|_| || d S r?   )r   r   in_header_docr   r   tagr   r   )rC   rN   r   r6   r6   r7   decompose_incoming_envelope  s
   
z'XmlDocument.decompose_incoming_envelopec                 C   s  |  |}t|tdr#| j| ju r|jstd | jr!|j	S d S | j
r|td }|d urd|v r=|dd\}}nd |}}|j|}|d urSd||f }	ntd|||j t||jjj|	d }
|
d u rxtd||	 t||
}td|||
 | j| }||||S )Nr.   :   r:   z6xsi:type namespace prefix '%s' in '%s' not found in %rz=xsi:type '%s' interpreted as class key '%s' is not recognizedz xsi:type '%s' overrides %r to %r)get_cls_attrsboolgetr   r   r   nillabler   rk   defaultrn   XSI_TYPEsplitnsmapr   r   r   r   classesr   r   )rC   rN   rO   element	cls_attrsxsi_typeprefixobjtyper;   classkeynewclasshandlerr6   r6   r7   from_element  sD   


zXmlDocument.from_elementc                 O   s   |  ||\}}| |}	|	j}
|
d ur)t|
tr)|
j|||||g|R i |S | j| }|d u r5|	j}|d u rI| j|||||g|R i |S |	j	rNd S ||d< ||||||g|R i |S )Nadd_type)
get_polymorphic_targetr   prot
isinstancerL   rQ   r{   r   null_to_parentexc)rC   rN   rO   rP   r4   r;   rS   rT   r   r   subprotr   r6   r6   r7   rM     s,   

zXmlDocument.to_parentc                 C   s
  || j | jfv s
J | jd| |jdu r&|jdu r#tdd|j |j|| j u r0|jj}n	|| ju r9|jj	}|j
du rHdgt|j |_n	| |||j
|_tjtjkr||| j u r|dttf }d}|jdurstj|j| jdd}td||f  | jd	| dS )
zTakes a MethodContext instance and a string containing ONE root xml
        tag.

        Returns the corresponding native python object.

        Not meant to be overridden.
        before_deserializeNClientzMethod %r not found.z%sRequest%sT)ri   rm   r   after_deserialize)r   r   event_manager
fire_event
descriptorin_errorr   r   
in_messageout_messager   len
_type_info	in_objectr   r   r   r   r   r   r   out_documentr   r   ri   r   )rC   rN   r   
body_classr   
outdoc_strr6   r6   r7   deserialize  s0   	






zXmlDocument.deserializec                 C   s^  || j | jfv s
J | jd| |jdur1td}| ||jj|j|| j	j
 }|d |_ng|| j u r;|jj}n	|| ju rD|jj}|jjtkrl| }t|j D ]\}\}}	| |	}
|||j| |	|
 qTn|j}|jdu rtd}| ||||| j	j
 }|d |_n| |||| j	j
 }| jr|jdurt|j | jd| |S )zUses ``ctx.out_object``, ``ctx.out_header`` or ``ctx.out_error`` to
        set ``ctx.out_body_doc``, ``ctx.out_header_doc`` and
        ``ctx.out_document`` as an ``lxml.etree._Element instance``.

        Not meant to be overridden.
        before_serializeNpunkr   after_serialize)r   r   r   r   	out_errorr   ElementrM   rF   r   r   get_tnsr   r   r   r   
body_styler	   	enumerater   itemsr   	_safe_set
out_object
out_streamincgenrj   )rC   rN   r   tmp_eltretvalresult_message_classresult_instikvattrsr6   r6   r7   	serialize7  sD   







zXmlDocument.serializec              
   C   s`   |du r| j }tj|j|| j| jdg|_tjt	j
kr.tdtttj|jdddf  dS dS )z6Sets an iterable of string fragments to ctx.out_stringN)rg   rm   ri   z%sResponse%s %sTrY   )rm   rg   )rg   r   r   r   rm   ri   
out_stringr   r   r   r   r   r   r   )rC   rN   r   r6   r6   r7   create_out_stringl  s   

zXmlDocument.create_out_stringc           	      c   s    |d u r	|  }t|j<}| ||||||}t|rDz
	 d V }|| q  tyC   z|t  W n	 t	y@   Y nw Y nw W d    n1 sNw   Y  t
|jdr`|j  d S d S )NTfinish)get_type_namer   xmlfiler   rM   r   sendr
   throwStopIterationr2   r  )	rC   rN   rO   rP   r;   r<   xfr   yr6   r6   r7   r   |  s0   
zXmlDocument.incgenc                 K   s8   |d ur
d||f }t |}|r|| jj|jt< |S r9   )r   get_type_name_nsr   r   attribr   )rC   rO   r;   r<   r   _r   r6   r6   r7   _gen_tag  s   zXmlDocument._gen_tagr   c           	      K   s6   | j |||fi |}| ||| j|_t|| d S r?   )r  
to_unicoderX   textr8   	rC   rN   rO   rP   r4   r;   r<   rT   eltr6   r6   r7   rw     s   z XmlDocument.byte_array_to_parentc           	      K   s2   | j |||fi |}| |||_t|| d S r?   )r  r  r  r8   r  r6   r6   r7   rv     s   zXmlDocument.modelbase_to_parentc           	      K   sX   t |trd S t |tr|jt d S | j|||fi |}|jt t|| d S r?   )
issubclassr)   r(   r  updateNIL_ATTRr  r8   r  r6   r6   r7   r     s   

zXmlDocument.null_to_parentc                 C   s   d S r?   r6   rC   rN   rO   r   r6   r6   r7   null_from_element  s   zXmlDocument.null_from_elementc           
      K   sT   |  |}	|j}|d u r|	j}t||}|r || jj|jt< |	| ||| d S r?   )
r   _nssub_nsr=   r  r   r   r  r   marshall)
rC   rN   rO   rP   r4   r;   r<   r   r  r   r6   r6   r7   rs     s   

zXmlDocument.xmldata_to_parentc           	      K   s|   |j }| |}|d u r|j}t||}|d ur<t|jttfr/||| 	|j|| j
 d S ||| 	|j| d S d S r?   )r  r   r  r=   r  r0   r'   r&   setr  rX   )	rC   rN   rO   rP   r4   r;   r<   r  r   r6   r6   r7   ry     s   


z"XmlDocument.xmlattribute_to_parentc                 c   s   i }|r| | jj}	|	d kr|	|t< n| |t< t|tjretj|||d}
|
	| | 
||||
}t|rcz
	 d V }|| q< tyb   z
|t  W Y d S  ty^   Y nw Y d S w d S |j||dM |D ]}|| qo| 
||||}t|rz
	 d V }|| q ty   z|t  W n	 ty   Y nw Y n	w W d    d S W d    d S 1 sw   Y  d S )N)r  )r  r   r   r   r  r   r   _Element
SubElementextend_get_members_etreer   r
  r
   r  r  r   r3   )rC   rN   rO   rP   r4   tag_namesubeltsr   r  tnnr  r   r  r   r6   r6   r7   gen_members_parent  s`   



" zXmlDocument.gen_members_parentc                 c   s   zHt |dd }|d ur?| ||||}|d ur?z
	 d V }|| q ty>   z|t  W n	 ty;   Y nw Y nw |j D ]\}}	| |	}
|
j	rRqDzt ||d }W n   d }Y |	j
j}|d u rm| }|	j
j}|d u rw|}|	j
j}|d ur|dkrt|tr	 d V }| ||	||||}|d urz
	 d V }|| q ty   z|t  W n	 ty   Y nw Y nw q|D ]6}| ||	||||}|d urz
	 d V }|| q ty   z|t  W n	 ty   Y nw Y qw qqD|d us|	j
jdkrG| ||	||||}|d urGz	 d V }|| q tyF } zz|| W n
 ty;   Y nw W Y d }~qDd }~ww qDW d S  tyU   Y d S w )N__extends__Tr   r   )getattrr#  r
  r
   r  r  r   r   r   r   
Attributesr  get_namespacesub_name
max_occursr   r%   rM   
min_occurs)rC   rN   rO   rP   r4   
parent_clsr   sv2r  r  sub_cls_attrssubvaluer  r,  mosvbr6   r6   r7   r#    s   






IzXmlDocument._get_members_etreec              	   K   sl   |  |}	|	j}
|
d ur|
}|d u r| }|	j}|d tfvr!|}t||}||}| |||||g |S r?   )r   r,  r  r  r   r=   get_serialization_instancer'  )rC   rN   rO   rP   r4   r;   r<   r   r  r   r,  r  r$  r6   r6   r7   rx   d  s   


zXmlDocument.complex_to_parentc           	   	   K   s   d| j  }t|jttjf rt|td|j n&t|jtr1t	|jdkr0t|t
d|ji n|jd u r7ntdt|j| j||||||ddS )Nz	{%s}Faultdetailr   zFault detail Must be dict, gotF)r   )ns_soap_envr   r7  r   r   r   r8   r   r   r   r   	TypeErrorr0   r'  )	rC   rN   rO   rP   r4   r;   r%  r  r$  r6   r6   r7   _fault_to_parent_imply  s   

z!XmlDocument._fault_to_parent_implc           	      O   s@   t dd| j|jf t d|jt d|jg}| ||||||S )N	faultcode%s:%srD   
faultactor)r   soap_envr;  rD   r=  r:  )	rC   rN   rO   rP   r4   r;   rS   rT   r%  r6   r6   r7   rp     s
   

zXmlDocument.fault_to_parentc                 K   sd   t dd| j|jf t dt|jjt d|jg}|jd kr(t	|t d|j | 
||||||S )Nr;  r<  rD   r=  r7  )r   r>  r;  r   r   rD   r  r=  r7  r8   r:  )rC   rN   rO   rP   r4   r;   r  r%  r6   r6   r7   rz     s   

z-XmlDocument.schema_validation_error_to_parentc                 K   s$   | j ||t||||fi | d S r?   )rv   r   )rC   rN   rO   rP   r4   r;   r<   rT   r6   r6   r7   rq     s   $zXmlDocument.enum_to_parentc                 K   s.   t |tr
t|}t|tt||| d S r?   )r   	STR_TYPESr   r   r8   r   r=   rC   rN   rO   rP   r4   r;   r<   r  r6   r6   r7   rr     s   

zXmlDocument.any_xml_to_parentc                 K   s   t |tt||| d S r?   )r8   r   r=   r@  r6   r6   r7   ro     s   zXmlDocument.any_to_parentc                 K   s:   t |trt|dkrt|}t|tt||| d S Nr   )r   r   r   r   r   r8   r   r=   r@  r6   r6   r7   ru     s   
zXmlDocument.any_html_to_parentc           	      K   s&   t t||}t|| t|| d S r?   )r   r=   r   r8   )	rC   rN   rO   rP   r4   r;   r<   r  r  r6   r6   r7   rt     s   
zXmlDocument.any_dict_to_parentc                 C   sJ  | |}||}tt}| |}|jd urJ|jD ].\}}	| |	j}
t|	jtt	fr8| 
|	j|j| j}n| 
|	j|j}||||	j|
 q|D ]}t|tjrUqL|jddd }||  d7  < ||d }|d u r|j|d |f\}}|d u r|j|jd |f\}}|d u rqL| |}|j}|dkrt||d }|d u rg }|| ||| n| |||}||||| |j D ]R\}}||d }|d u r|j|d |f\}}|d u rq| |}|j}|dkr	t||d }|d u rg }|| 
|j| n| 
|j|}||||j| qqL|j D ]S\}}||d }|d u rA|j|d |f\}}|d u rAq t|tsIq t|jtt	fr\| 
|j|| j}n| 
|j|}| |j}||||j| q | j| ju r| D ]#\}}||d}| |}||jk s||jkrtdd| q|S )N}r   r   zClient.ValidationErrorz1%r member does not respect frequency constraints.) get_deserialization_instanceget_flat_type_infor   intr   _xml_tag_body_asr0   r  r'   r&   from_unicoder  rX   r   r   r   _Commentr   r   r   _type_info_altr-  r)  r1   r   r  r   r)   r   r   r.  r   )rC   rN   rO   r  rP   flat_type_infofrequenciesr   xtba_key	xtba_type
xtba_attrsr   ckeymembermember_attrsr3  	value_str	submembersubmember_attrsvalattrr6   r6   r7   r     s   










z XmlDocument.complex_from_elementc                 C   s6   g }|j  \}| D ]}|| ||| q|S r?   )r   valuesgetchildrenr1   r   )rC   rN   rO   r   r   
serializerchildr6   r6   r7   r~   "  s
   zXmlDocument.array_from_elementc                 c   s0    |j  \}| D ]
}| |||V  qd S r?   )r   rY  rZ  r   )rC   rN   rO   r   r[  r\  r6   r6   r7   r   +  s
   z!XmlDocument.iterable_from_elementc                 C   s0   | j | ju r|||jst|jt||jS r?   )r   r   validate_stringr  r   r)  r  r6   r6   r7   r   1  s
   
zXmlDocument.enum_from_elementc                 C   sJ   | dj}| dj}| d}|d ur|j}| d}|||||dS )Nr;  rD   r=  r7  )r;  rD   r=  r7  )findr  )rC   rN   rO   r   coder   factorr7  r6   r6   r7   r   7  s   

zXmlDocument.fault_from_elementc                 C   s    |  }d }|r|  d }|S rA  )rZ  rC   rN   rO   r   childrenr   r6   r6   r7   r}   B  s
   zXmlDocument.xml_from_elementc                 C   s>   |  }d }t|dkr|d }|S t|dkrtj| }|S )Nr   r   )rZ  r   r   r   ra  r6   r6   r7   r|   K  s   
zXmlDocument.html_from_elementc                 C   s   |  }|r
t|S d S r?   )rZ  r   )rC   rN   rO   r   rb  r6   r6   r7   r   X  s   zXmlDocument.dict_from_elementc                 C   sf   | j | ju r|||jst|j|j}|d u rd}| ||}| j | ju r1|||s1t||S )N r   r   r]  r  r   rH  validate_native)rC   rN   rO   r   sr   r6   r6   r7   r   _  s   

z XmlDocument.unicode_from_elementc                 C   sV   | j | ju r|||jst|j| ||j}| j | ju r)|||s)t||S r?   rd  rC   rN   rO   r   r   r6   r6   r7   r   p  s   

zXmlDocument.base_from_elementc                 C   sZ   | j | ju r|||jst|j| ||j| j}| j | ju r+|||s+t||S r?   )r   r   r]  r  r   rH  rX   re  rg  r6   r6   r7   r   }  s   

z#XmlDocument.byte_array_from_element)NNTTTNFFFFTFFFTTFFTNTFr?   )F)r   )NF)?rG   rH   rI   rJ   r0   objectr   	mime_typer*   default_binary_encodingr  r,   addr   r   r>  r8  r   ns_soap_encrA   r   r   r   r   r   r   r   rM   r   r  r  r   r   r  rw   rv   r   r  rs   ry   r'  r#  rx   r:  rp   rz   rq   rr   ro   ru   rt   r   r~   r   r   r   r}   r|   r   r   r   r   rK   r6   r6   rE   r7   rU      s     

U

	/+
5






/
^
	
e		rU   )NrJ   r   	getLoggerr   r   inspectr   collectionsr   r   r   r   lxml.builderr   
lxml.etreer   r   spyner	   
spyne.utilr
   r   spyne.util.sixr   r   spyne.util.cdictr   spyne.util.etreeconvr   r   r   spyne.const.xmlr   r   spyne.errorr   r   spyne.const.ansi_colorr   r   r   r   r   r   spyne.modelr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   spyne.model.binaryr*   spyne.model.enumr+   spyne.protocolr,   r-   PY2r   unicoder?  bytesr  r   r8   r=   r>   rL   rU   r6   r6   r6   r7   <module>   sN   

@
	