ó
ÊVãKc           @   sì   d  Z  d d l m Z d d l Td d l Td d l m Z d d l m Z d d l	 m
 Z
 m Z d d l m Z d d l m Z e e ƒ Z e j j d	 ƒ e j j d
 ƒ e j j d ƒ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s)   
Provides literal I{marshaller} classes.
iÿÿÿÿ(   t	   getLogger(   t   *(   t   Core(   t   Typer(   t   GraphResolvert   Frame(   t   Element(   t   Factoryt   typet   realt   ancestryt   Typedc           B   s¡   e  Z d  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s5  
    A I{typed} marshaller.
    This marshaller is semi-typed as needed to support both
    I{document/literal} and I{rpc/literal} soap message styles.
    @ivar schema: An xsd schema.
    @type schema: L{xsd.schema.Schema}
    @ivar resolver: A schema type resolver.
    @type resolver: L{GraphResolver}
    c         C   s5   t  j |  ƒ | |  _ | |  _ t |  j ƒ |  _ d S(   s  
        @param schema: A schema object
        @type schema: L{xsd.schema.Schema}
        @param xstq: The B{x}ml B{s}chema B{t}ype B{q}ualified flag indicates
            that the I{xsi:type} attribute values should be qualified by namespace.
        @type xstq: bool
        N(   R   t   __init__t   schemat   xstqR   t   resolver(   t   selfR   R   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR   8   s    		c         C   s   |  j  j ƒ  d  S(   N(   R   t   reset(   R   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR   E   s    c         C   s€  t  j d | ƒ | j d  k r‡ | j } | j d ƒ rH d | d } n  |  j j | | j ƒ | _ | j d  k rt	 | j ƒ ‚ qn€ d  } t
 | j t ƒ râ |  j j | j ƒ } | d  k râ t  j d | j ƒ | j } qâ n  t | j d | ƒ} |  j j | ƒ |  j j ƒ  } | j | _ | j | _ |  j | ƒ |  j | ƒ |  j | ƒ rxt  j d | ƒ |  j j ƒ  t St Sd  S(   Ns   starting content:
%st   _t   @i   s   object has no type informationt   resolveds   skipping (optional) content:
%s(   t   logt   debugR   t   Nonet   tagt
   startswithR   t   findt   valuet   TypeNotFoundt
   isinstancet   Objectt   knownR   t   pusht   topR   R	   R
   t	   translatet   sortt   skipt   popt   Falset   True(   R   t   contentt   nameR   t   frame(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt   startH   s4    	c         C   s   |  j  j ƒ  d  S(   N(   R   R%   (   R   R(   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt   suspendm   s    c         C   s   |  j  j t | j ƒ ƒ d  S(   N(   R   R    R   R   (   R   R(   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt   resumeu   s    c         C   sX   t  j d | ƒ |  j j ƒ  j } | | j k rA |  j j ƒ  n t d | | f ‚ d  S(   Ns   ending content:
%ss*   content (end) mismatch: top=(%s) cont=(%s)(   R   R   R   R!   R   R%   t	   Exception(   R   t   parentR(   t   current(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt   end}   s    c         C   s~   | j  j ƒ  } | j  j rK t | j d | ƒ} | j | d | d ƒ n t | j ƒ } |  j | | ƒ t j d | ƒ | S(   Nt   nsi    i   s   created - node:
%s(	   R   t	   namespacet   form_qualifiedR   R   t	   addPrefixt   encodeR   R   (   R   R(   R2   t   node(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR7   Œ   s    c         C   s   | j  j r | j ƒ  n  d  S(   N(   R   t   nillablet   setnil(   R   R7   R(   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR9   ›   s    c         C   s,   | j  j } | d  k r n | j | ƒ | S(   N(   R   t   defaultR   t   setText(   R   R7   R(   R:   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt
   setdefault£   s
    c         C   s;   | j  j ƒ  r t Sx! | j D] } | j ƒ  r t Sq Wt S(   N(   R   t   optionalR'   R
   R&   (   R   R(   t   a(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR=   ¯   s    c         C   s‰   | j  j ƒ  r d  S| j j ƒ  s& d  S| j  j ƒ  | j k rB d  Sd  } | j j } |  j rr | j j d ƒ } n  t	 j
 | | | ƒ d  S(   Nt   ns1(   R   t   anyR	   t	   extensiont   resolveR   R)   R   R3   R   t   manual(   R   R7   R(   R2   R)   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR6   ·   s    	c         C   sZ   |  j  | ƒ rV | j } | d k r( t St | t t f ƒ rV t | ƒ d k rV t Sn  t S(   sD  
        Get whether to skip this I{content}.
        Should be skipped when the content is optional
        and either the value=None or the value is an empty list.
        @param content: The content to skip.
        @type content: L{Object}
        @return: True if content is to be skipped.
        @rtype: bool
        i    N(	   R=   R   R   R'   R   t   listt   tuplet   lenR&   (   R   R(   t   v(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR$   È   s    
	'c         C   s;   | j  j ƒ  r t Sx! | j D] } | j ƒ  r t Sq Wt S(   N(   R   R=   R'   R
   R&   (   R   R(   R>   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR=   Ú   s    c         C   s‡   | j  } | d k r d St | t ƒ re | j j } t j | | ƒ | _  | j  j } | j	 | _
 d S| j j | t ƒ } | | _  |  S(   sj  
        Translate using the XSD type information.
        Python I{dict} is translated to a suds object.  Most
        importantly, primative values are translated from python
        types to XML types using the XSD type.
        @param content: The content to translate.
        @type content: L{Object}
        @return: self
        @rtype: L{Typed}
        N(   R   R   R   t   dictR	   R)   R   t   objectt   __metadata__R   t   sxtypeR"   R&   (   R   R(   RG   t   clst   md(    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR"   â   s    		c         C   s=   | j  } t | t ƒ r9 | j } |  j | j ƒ | _ n  |  S(   sé   
        Sort suds object attributes based on ordering defined
        in the XSD type information.
        @param content: The content to sort.
        @type content: L{Object}
        @return: self
        @rtype: L{Typed}
        (   R   R   R   RJ   t   orderingR	   (   R   R(   RG   RM   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR#   ú   s
    			c         C   sn   g  } xa | j  ƒ  D]S \ } } | j } | j d k r= q n  | j ƒ  rY d | j } n  | j | ƒ q W| S(   s÷   
        Get the attribute ordering defined in the specified
        XSD type information.
        @param type: An XSD type object.
        @type type: SchemaObject
        @return: An ordered list of attribute names.
        @rtype: list
        s   _%sN(   RB   R)   R   t   isattrt   append(   R   R   t   resultt   childR
   R)   (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyRN   	  s    		(   t   __name__t
   __module__t   __doc__R'   R   R   R+   R,   R-   R1   R7   R9   R<   R=   R6   R$   R"   R#   RN   (    (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyR   -   s"   			%												t   Literalc           B   s   e  Z d  Z RS(   sž   
    A I{literal} marshaller.
    This marshaller is semi-typed as needed to support both
    I{document/literal} and I{rpc/literal} soap message styles.
    (   RS   RT   RU   (    (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyRV     s   N(   RU   t   loggingR    t   sudst   suds.mxt   suds.mx.coreR   t   suds.mx.typerR   t   suds.resolverR   R   t   suds.sax.elementR   t   suds.sudsobjectR   RS   R   t   Contentt
   extensionsRP   R   RV   (    (    (    sI   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/mx/literal.pyt   <module>   s   

	ð