Ñò
—ã=Pc           @   sm   d  Z  d d k l Z d d k Td d k Td d k l Z d d k l	 Z	 e e
 ƒ Z d d	 d „  ƒ  YZ d S(
   s   
Provides sx typing classes.
iÿÿÿÿ(   t	   getLogger(   t   *(   t	   Namespace(   t   Textt   Typerc           B   sÆ   e  Z d  Z h d e i f e 6d e i f e 6d e i f e 6d e i f e 6d e i f e	 6d e i f e
 6d e i f e 6Z e d
 d „ ƒ Z e d
 d „ ƒ Z e d „  ƒ Z e d	 „  ƒ Z RS(   s   
    Provides XML node typing as either automatic or manual.
    @cvar types:  A dict of class to xs type mapping.
    @type types: dict
    t   intt   longt   floatt   stringt   booleanc         C   s¢   | d j o | i ƒ  } n t | t ƒ o= |  i | ƒ } | i d j o | S| i | i ƒ  f } n% |  i i | i	 |  i i t
 ƒ ƒ } |  i | | Œ | S(   sÓ  
        Automatically set the node's xsi:type attribute based on either I{value}'s
        class or the class of the node's text.  When I{value} is an unmapped class,
        the default type (xs:any) is set.
        @param node: An XML node
        @type node: L{sax.element.Element}
        @param value: An object that is or would be the node's text.
        @type value: I{any}
        @return: The specified node.
        @rtype: L{sax.element.Element}
        N(   t   Nonet   getTextt
   isinstancet   Objectt   knownt   namet	   namespacet   typest   gett	   __class__t   strt   manual(   t   clst   nodet   valueR   t   tm(    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyt   auto/   s    $c         C   s²   d i  t i d d f ƒ } | i t i d t i d ƒ | d j o | i | | ƒ nT |  i | | ƒ } d i  | d | f ƒ } | i | | ƒ | i | d | d ƒ | S(   sú  
        Set the node's xsi:type attribute based on either I{value}'s
        class or the class of the node's text.  Then adds the referenced
        prefix(s) to the node's prefix mapping.
        @param node: An XML node
        @type node: L{sax.element.Element}
        @param tval: The name of the schema type.
        @type tval: str
        @param ns: The XML namespace of I{tval}.
        @type ns: (prefix, uri)
        @return: The specified node.
        @rtype: L{sax.element.Element}
        t   :i    t   typei   N(   t   joint   NSt   xsinst	   addPrefixR
   t   sett	   genprefix(   R   R   t   tvalt   nst   xtat   qname(    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyR   H   s    c         C   sv   xc t  d d ƒ D]R } d | } | i | d d ƒ} | d j p | | d j o | | d f Sq Wt d ƒ ‚ d S(   s  
        Generate a prefix.
        @param node: An XML node on which the prefix will be used.
        @type node: L{sax.element.Element}
        @param ns: A namespace needing an unique prefix.
        @type ns: (prefix, uri)
        @return: The I{ns} with a new prefix.
        i   i   s   ns%dt   defaults   auto prefix, exhaustedN(   t   ranget   resolvePrefixR
   t	   Exception(   R   R   R$   t   nt   pt   u(    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyR"   b   s    
 
c         C   s(   y | i  } | i } | SWn n Xd  S(   N(   t   __metadata__t   sxtype(   R   t   objectt   mdR   (    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyR   s   s    		N(   t   __name__t
   __module__t   __doc__R   t   xsdnsR   R   R   R   t   unicodeR   t   boolR   t   classmethodR
   R   R   R"   R   (    (    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyR      s   N(    (   R4   t   loggingR    t   sudst   suds.mxt   suds.saxR   R   t   suds.sax.textR   R2   t   logR   (    (    (    sL   /usr/local/lib/python2.6/dist-packages/suds-0.3.7-py2.6.egg/suds/mx/typer.pyt   <module>   s   

