³ò
—ã=Pc        	   @   s  d  Z  d d k Z d d k l Z d d k Td d k l Z l Z d d k l	 Z	 d d k
 l Z l Z l Z e e ƒ Z d d d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d d „  ƒ  YZ d e f d „  ƒ  YZ d S(   sf   
The I{resolver} module provides a collection of classes that
provide wsdl/xsd named type resolution.
iÿÿÿÿN(   t	   getLogger(   t   *(   t   splitPrefixt	   Namespace(   t   Object(   t
   BlindQueryt	   TypeQueryt   qualifyt   Resolverc           B   s#   e  Z d  Z d „  Z e d „ Z RS(   sx   
    An I{abstract} schema-type resolver.
    @ivar schema: A schema object.
    @type schema: L{xsd.schema.Schema}
    c         C   s   | |  _  d S(   s\   
        @param schema: A schema object.
        @type schema: L{xsd.schema.Schema}
        N(   t   schema(   t   selfR	   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   __init__'   s    c         C   s¥   t  i d | ƒ t | |  i i |  i i ƒ } t | ƒ } | i |  i ƒ } | d j o t  i	 d | ƒ d Sn t  i d | t
 | ƒ ƒ | o | i ƒ  } n | S(   sx  
        Get the definition object for the schema object by name.
        @param name: The name of a schema object.
        @type name: basestring
        @param resolved: A flag indicating that the fully resolved type
            should be returned.
        @type resolved: boolean
        @return: The found schema I{type}
        @rtype: L{xsd.sxbase.SchemaObject}
        s   searching schema for (%s)s   (%s) not-founds   found (%s) as (%s)N(   t   logt   debugR   R	   t   roott   tnsR   t   executet   Nonet   errort   Reprt   resolve(   R
   t   namet   resolvedt   qreft   queryt   result(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   find.   s    (   t   __name__t
   __module__t   __doc__R   t   TrueR   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR       s   	t   PathResolverc           B   si   e  Z d  Z d d „ Z e d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 e f d
 „  ƒ  YZ RS(   sâ   
    Resolveds the definition object for the schema type located at the specified path.
    The path may contain (.) dot notation to specify nested types.
    @ivar wsdl: A wsdl object.
    @type wsdl: L{wsdl.Definitions}
    t   .c         C   sL   t  i |  | i ƒ | |  _ t i d ƒ |  _ t i d | d ƒ |  _ d S(   sž   
        @param wsdl: A schema object.
        @type wsdl: L{wsdl.Definitions}
        @param ps: The path separator character
        @type ps: char
        s   ({)(.+)(})(.+)s   ({.+})*[^\%s]+i    N(   R   R   R	   t   wsdlt   ret   compilet   altpt   splitp(   R
   R!   t   ps(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   N   s    	c         C   sÀ   d } |  i | ƒ } y} |  i | ƒ } t | ƒ d j o: | i d t ƒ } |  i | | ƒ } |  i | | ƒ } n | o | i d t ƒ } n Wn' t i	 j
 o t
 i d | ƒ n X| S(   sD  
        Get the definition object for the schema type located at the specified path.
        The path may contain (.) dot notation to specify nested types.
        Actually, the path separator is usually a (.) but can be redefined
        during contruction.
        @param path: A (.) separated path to a schema type.
        @type path: basestring
        @param resolved: A flag indicating that the fully resolved type
            should be returned.
        @type resolved: boolean
        @return: The found schema I{type}
        @rtype: L{xsd.sxbase.SchemaObject}
        i   t	   nobuiltins   path: "%s", not-foundN(   R   t   splitR   t   lenR   R   t   brancht   leafR   t   BadPathR   R   (   R
   t   pathR   R   t   parts(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   Z   s    c         C   sž   d } | d } t i d | ƒ |  i | d ƒ } t | ƒ } | i |  i ƒ } | d j o# t i d | ƒ t i	 | ƒ ‚ n t i d | t
 | ƒ ƒ | S(   sµ   
        Find the path root.
        @param parts: A list of path parts.
        @type parts: [str,..]
        @return: The root.
        @rtype: L{xsd.sxbase.SchemaObject}
        i    s   searching schema for (%s)s   (%s) not-founds   found (%s) as (%s)N(   R   R   R   R   R   R   R	   R   R   R,   R   (   R
   R.   R   R   R   R   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   v   s    
c         C   s»   | } x® | d d !D]Ÿ } t  | ƒ d } t i d t | ƒ | ƒ | i | ƒ \ } } | d j o# t i d | ƒ t i | ƒ ‚ q | i	 d t
 ƒ } t i d | t | ƒ ƒ q W| S(   s)  
        Traverse the path until the leaf is reached.
        @param parts: A list of path parts.
        @type parts: [str,..]
        @param root: The root.
        @type root: L{xsd.sxbase.SchemaObject}
        @return: The end of the branch.
        @rtype: L{xsd.sxbase.SchemaObject}
        i   iÿÿÿÿs   searching parent (%s) for (%s)s   (%s) not-foundR'   s   found (%s) as (%s)N(   R   R   R   R   t	   get_childR   R   R   R,   R   R   (   R
   R   R.   R   t   partR   t   ancestry(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR*   ‹   s    
 c         C   sz   t  | d ƒ d } | i d ƒ o | i | d ƒ \ } } n | i | ƒ \ } } | d j o t i | ƒ ‚ n | S(   s  
        Find the leaf.
        @param parts: A list of path parts.
        @type parts: [str,..]
        @param parent: The leaf's parent.
        @type parent: L{xsd.sxbase.SchemaObject}
        @return: The leaf.
        @rtype: L{xsd.sxbase.SchemaObject}
        iÿÿÿÿi   t   @N(   R   t
   startswitht   get_attributeR/   R   R   R,   (   R
   t   parentR.   R   R   R-   R1   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR+   ¢   s    
c         C   s_   |  i  i | ƒ } | d j o  t | |  i i |  i i ƒ Sn | i d ƒ | i d ƒ f Sd S(   s>  
        Qualify the name as either:
          - plain name
          - ns prefixed name (eg: ns0:Person)
          - fully ns qualified name (eg: {http://myns-uri}Person)
        @param name: The name of an object in the schema.
        @type name: str
        @return: A qualifed name.
        @rtype: qname
        i   i   N(   R$   t   matchR   R   R!   R   R   t   group(   R
   R   t   m(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   µ   s     c         C   sm   g  } d } xZ |  i  i | | ƒ } | d j o Pn | i ƒ  \ } } | i | | | !ƒ | d } q | S(   s  
        Split the string on (.) while preserving any (.) inside the
        '{}' alternalte syntax for full ns qualification.
        @param s: A plain or qualifed name.
        @type s: str
        @return: A list of the name's parts.
        @rtype: [str,..]
        i    i   N(   R%   R6   R   t   spant   append(   R
   t   sR.   t   bR8   t   e(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR(   Æ   s    	R,   c           B   s   e  Z RS(    (   R   R   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR,   Ú   s    (   R   R   R   R   R   R   R   R*   R+   R   R(   t	   ExceptionR,   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   F   s   					t   TreeResolverc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   sû   
    The tree resolver is a I{stateful} tree resolver
    used to resolve each node in a tree.  As such, it mirrors
    the tree structure to ensure that nodes are resolved in
    context.
    @ivar stack: The context stack.
    @type stack: list
    c         C   s    t  i |  | ƒ t ƒ  |  _ d S(   s\   
        @param schema: A schema object.
        @type schema: L{xsd.schema.Schema}
        N(   R   R   t   Stackt   stack(   R
   R	   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   ç   s    c         C   s   t  ƒ  |  _ d S(   s-   
        Reset the resolver's state.
        N(   R@   RA   (   R
   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   resetï   s    c         C   s\   t  | t ƒ o
 | } n t | ƒ } |  i i | ƒ t i d t | ƒ t |  i ƒ ƒ | S(   s®   
        Push an I{object} onto the stack.
        @param x: An object to push.
        @type x: L{Frame}
        @return: The pushed frame.
        @rtype: L{Frame}
        s   push: (%s)
%s(   t
   isinstancet   FrameRA   R:   R   R   R   (   R
   t   xt   frame(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   pushõ   s    
"c         C   s-   t  |  i ƒ o |  i d Sn t i ƒ  Sd S(   s‚   
        Get the I{frame} at the top of the stack.
        @return: The top I{frame}, else None.
        @rtype: L{Frame}
        iÿÿÿÿN(   R)   RA   RD   t   Empty(   R
   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   top  s    c         C   sZ   t  |  i ƒ o9 |  i i ƒ  } t i d t | ƒ t |  i ƒ ƒ | Sn t i d ƒ d S(   s   
        Pop the frame at the top of the stack.
        @return: The popped frame, else None.
        @rtype: L{Frame}
        s   pop: (%s)
%ss   stack empty, not-poppedN(   R)   RA   t   popR   R   R   R   (   R
   t   popped(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRJ     s    "c         C   s   t  |  i ƒ S(   sl   
        Get the current stack depth.
        @return: The current stack depth.
        @rtype: int
        (   R)   RA   (   R
   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   depth  s    c         C   sO   t  i d t | ƒ | ƒ | i d ƒ o | i | d ƒ Sn | i | ƒ Sd S(   s    get a child by name s   searching parent (%s) for (%s)R2   i   N(   R   R   R   R3   R4   R/   (   R
   R   R5   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   getchild&  s    (
   R   R   R   R   RB   RG   RI   RJ   RL   RM   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR?   Ý   s   						t   NodeResolverc           B   sD   e  Z d  Z d „  Z e e d „ Z e d „ Z d „  Z d „  Z	 RS(   sÉ   
    The node resolver is a I{stateful} XML document resolver
    used to resolve each node in a tree.  As such, it mirrors
    the tree structure to ensure that nodes are resolved in
    context.
    c         C   s   t  i |  | ƒ d S(   s\   
        @param schema: A schema object.
        @type schema: L{xsd.schema.Schema}
        N(   R?   R   (   R
   R	   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   7  s    c         C   sÊ   | i  } |  i ƒ  i } | d j o |  i | | ƒ \ } } n |  i | | ƒ \ } } |  i | ƒ } | d j o | Sn | o+ t | d | d | ƒ}	 |  i |	 ƒ }
 n | o | i	 ƒ  } n | S(   sÁ  
        @param node: An xml node to be resolved.
        @type node: L{sax.element.Element}
        @param resolved: A flag indicating that the fully resolved type should be
            returned.
        @type resolved: boolean
        @param push: Indicates that the resolved type should be
            pushed onto the stack.
        @type push: boolean
        @return: The found schema I{type}
        @rtype: L{xsd.sxbase.SchemaObject}
        R   R1   N(
   R   RI   R   R   R   RM   t   knownRD   RG   R   (   R
   t   nodeR   RG   R   R5   R   R1   RO   RF   t   pushed(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   >  s    	c         C   sŠ   d | } |  i  ƒ  i } | d j o |  i | t ƒ \ } } n |  i | | ƒ \ } } | d j o | Sn | o | i ƒ  } n | S(   sX  
        Find an attribute type definition.
        @param name: An attribute name.
        @type name: basestring
        @param resolved: A flag indicating that the fully resolved type should be
            returned.
        @type resolved: boolean
        @return: The found schema I{type}
        @rtype: L{xsd.sxbase.SchemaObject}
        s   @%sN(   RI   R   R   R   RP   RM   R   (   R
   R   R   R5   R   R1   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   findattr[  s    
c         C   sP   t  i d | ƒ t | | | i ƒ  ƒ } t | ƒ } | i |  i ƒ } | g  f S(   s"    blindly query the schema by name s   searching schema for (%s)(   R   R   R   t	   namespaceR   R   R	   (   R
   R   RP   R   R   R   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   r  s
    c         C   s^   | i  d t i ƒ } | d j o d Sn t | | | i ƒ  ƒ } t | ƒ } | i |  i ƒ S(   s&    resolve type referenced by @xsi:type t   typeN(	   t   getR   t   xsinsR   R   RS   R   R   R	   (   R
   RP   t   refR   R   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRO   z  s    (
   R   R   R   R   t   FalseR   R   RR   R   RO   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRN   /  s   		t   GraphResolverc           B   sA   e  Z d  Z d „  Z e e d „ Z d „  Z d „  Z d „  Z	 RS(   sÍ   
    The graph resolver is a I{stateful} L{Object} graph resolver
    used to resolve each node in a tree.  As such, it mirrors
    the tree structure to ensure that nodes are resolved in
    context.
    c         C   s   t  i |  | ƒ d S(   s\   
        @param schema: A schema object.
        @type schema: L{xsd.schema.Schema}
        N(   R?   R   (   R
   R	   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   Œ  s    c         C   sï   d } |  i ƒ  i } | d j o |  i | ƒ \ } } n |  i | | ƒ \ } } | d j o d Sn t | t ƒ o |  i | ƒ } n | o+ t | d | d | ƒ}	 |  i	 |	 ƒ }
 n | o' | d j o | i
 ƒ  } që | } n | S(   s  
        @param name: The name of the object to be resolved.
        @type name: basestring
        @param object: The name's value.
        @type object: (any|L{Object}) 
        @param resolved: A flag indicating that the fully resolved type
            should be returned.
        @type resolved: boolean
        @param push: Indicates that the resolved type should be
            pushed onto the stack.
        @type push: boolean
        @return: The found schema I{type}
        @rtype: L{xsd.sxbase.SchemaObject}
        R   R1   N(   R   RI   R   R   RM   RC   R   RO   RD   RG   R   (   R
   R   t   objectR   RG   RO   R5   R   R1   RF   RQ   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   “  s"    
c         C   s‹   t  i d | ƒ |  i } |  i ƒ  } | d j o t | | i | i ƒ } n t | | i | i ƒ } t | ƒ } | i	 | ƒ } | g  f S(   s"    blindly query the schema by name s   searching schema for (%s)N(
   R   R   R	   R!   R   R   R   R   R   R   (   R
   R   R	   R!   R   R   R   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   ¶  s    	c         C   s,   |  i  i } | d j o d Sn | i Sd S(   s    get the wsdl N(   R	   t	   containerR   R!   (   R
   R[   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR!   Ã  s    c         C   s(   y | i  } | i } | SWn n Xd S(   s1    get the type specified in the object's metadata N(   t   __metadata__t   sxtype(   R
   RZ   t   mdRO   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRO   Ë  s    		(
   R   R   R   R   RX   R   R   R   R!   RO   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRY   „  s   	#		RD   c           B   s3   e  Z d d d  „ Z d „  Z d d d „  ƒ  YZ RS(   c         C   sB   | |  _  | d  j o | i ƒ  } n | i ƒ  |  _ | |  _ d  S(   N(   RT   R   R   R   R1   (   R
   RT   R   R1   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR   Ö  s
    	c         C   sG   d t  |  i ƒ t  |  i ƒ g  } |  i D] } | t  | ƒ q) ~ f S(   Ns   %s
%s
%s(   R   RT   R   R1   (   R
   t   _[1]t   t(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   __str__Ý  s    RH   c           B   s   e  Z d  „  Z RS(   c         C   s   | d j o d Sn d  Sd  S(   NR1   (    (   R   (   R
   R   (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   __getattr__ä  s    (   R   R   Rb   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRH   ã  s   N(    (    (   R   R   R   R   Ra   RH   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyRD   Õ  s   	R@   c           B   s   e  Z d  „  Z RS(   c         C   s7   g  } x! |  D] } | i  t | ƒ ƒ q Wd i | ƒ S(   Ns   
(   R:   t   reprt   join(   R
   R   t   item(    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyt   __repr__ì  s
     (   R   R   Rf   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pyR@   ë  s   (    (    (   R   R"   t   loggingR    t   sudst   suds.saxR   R   t   suds.sudsobjectR   t   suds.xsd.queryR   R   R   R   R   R   R   R?   RN   RY   RD   t   listR@   (    (    (    s%   suds-0.3.7-py2.6.egg/suds/resolver.pys   <module>   s   
&—RUQ