ó
IžjLc           @   sS   d  Z  d d l m Z d d l Td d l m Z e e ƒ Z d d d „  ƒ  YZ d S(	   sB   
The I{builder} module provides an wsdl/xsd defined types factory
iÿÿÿÿ(   t	   getLogger(   t   *(   t   Factoryt   Builderc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sE    Builder used to construct an object for types defined in the schema c         C   s   | |  _  d S(   sn   
        @param resolver: A schema object name resolver.
        @type resolver: L{resolver.Resolver}
        N(   t   resolver(   t   selfR   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyt   __init__   s    c   
      C   s  t  | t ƒ r? |  j j | ƒ } | d k rE t | ƒ ‚ qE n | } | j } | j ƒ  rl t j	 | ƒ } n t j
 | ƒ } | j ƒ  } | j } | | _ |  j | ƒ | _ g  } |  j | | ƒ xF | j ƒ  D]8 \ } }	 |  j | |	 ƒ rò qÎ n  |  j | | | ƒ qÎ W| S(   sG    build a an object for the specified typename as defined in the schema N(   t
   isinstancet
   basestringR   t   findt   Nonet   TypeNotFoundt   namet   mixedR   t   propertyt   objectt   resolvet   __metadata__t   sxtypet   orderingt   add_attributest   childrent
   skip_childt   process(
   R   R   t   typet   clst   datat   resolvedt   mdt   historyt   childt   ancestry(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyt   build&   s(    			c   	      C   si  | | k r d S| j  ƒ  r  d S| j | ƒ | j ƒ  } d } | j ƒ  rT g  } n~ t | ƒ d k rÒ | j ƒ  r™ t j | j	 ƒ } | j
 } | | _ qÒ t j | j	 ƒ } | j
 } | | _ |  j | ƒ | _ n  t | | j	 | ƒ | d k	 rú | } n  t | t ƒ se|  j | | ƒ xI | j ƒ  D]8 \ } } |  j | | ƒ rJq&n  |  j | | | ƒ q&Wn  d S(   s6    process the specified type then process its children Ni    (   t   enumt   appendR   R
   t	   unboundedt   lenR   R   R   R   R   R   R   R   t   setattrR   t   listR   R   R   R   (	   R   R   R   R   R   t   valueR   R   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyR   ?   s6    					c         C   sJ   xC | j  ƒ  D]5 \ } } d | j } | j ƒ  } t | | | ƒ q Wd S(   s    add required attributes s   _%sN(   t
   attributesR   t   get_defaultR%   (   R   R   R   t   attrR   R   R'   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyR   _   s    c         C   s5   | j  ƒ  r t Sx | D] } | j ƒ  r t Sq Wt S(   s0    get whether or not to skip the specified child (   t   anyt   Truet   choicet   False(   R   R   R   t   x(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyR   f   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 ordering s   _%sN(   R   R   R
   t   isattrR"   (   R   R   t   resultR   R   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyR   n   s    	(	   t   __name__t
   __module__t   __doc__R   R    R   R   R   R   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyR      s   			 		N(    (	   R4   t   loggingR    t   sudst   suds.sudsobjectR   R2   t   logR   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/builder.pyt   <module>   s
   
