ó
¾œ~Lc           @   s»   d  Z  d 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 d d l m Z e e ƒ Z d d d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s'   
Contains xml document reader classes.
iÿÿÿÿ(   t   Parser(   t   Request(   t   Cachet   NoCache(   t   DocumentStore(   t   PluginContainer(   t	   getLoggert   Readerc           B   s    e  Z d  Z d „  Z d „  Z RS(   sy   
    The reader provides integration with cache.
    @ivar options: An options object.
    @type options: I{Options}
    c         C   s   | |  _  t | j ƒ |  _ d S(   sV   
        @param options: An options object.
        @type options: I{Options}
        N(   t   optionsR   t   plugins(   t   selfR   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyt   __init__(   s    	c         C   s    t  t | ƒ ƒ } d | | f S(   so   
        Mangle the name by hashing the I{name} and appending I{x}.
        @return: the mangled name.
        s   %s-%s(   t   abst   hash(   R
   t   namet   xt   h(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyt   mangle0   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR   !   s   	t   DocumentReaderc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   so   
    The XML document reader provides an integration
    between the SAX L{Parser} and the document cache.
    c         C   s�   |  j  ƒ  } |  j | d ƒ } | j | ƒ } | d k r[ |  j | ƒ } | j | | ƒ n  |  j j j d | d | j	 ƒ  ƒ | S(   s¤  
        Open an XML document at the specified I{url}.
        First, the document attempted to be retrieved from
        the I{object cache}.  If not found, it is downloaded and
        parsed using the SAX parser.  The result is added to the
        cache for the next open().
        @param url: A document url.
        @type url: str.
        @return: The specified XML document.
        @rtype: I{Document}
        t   documentt   urlN(
   t   cacheR   t   gett   Nonet   downloadt   putR	   R   t   parsedt   root(   R
   R   R   t   idt   d(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyt   open?   s    "c         C   s˜   t  ƒ  } | j | ƒ } | d k rB |  j j j t | ƒ ƒ } n  | j ƒ  } | j ƒ  |  j j	 j
 d | d | ƒ } | j	 } t ƒ  } | j d | ƒ S(   s¯   
        Download the docuemnt.
        @param url: A document url.
        @type url: str.
        @return: A file pointer to the docuemnt.
        @rtype: file-like
        R   R   t   stringN(   R   R!   R   R   t	   transportR   t   readt   closeR	   R   t   loadedR    t   parse(   R
   R   t   storet   fpt   contentt   ctxt   sax(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR   T   s    	
		c         C   s'   |  j  j d k r |  j  j St ƒ  Sd S(   sw   
        Get the cache.
        @return: The I{options} when I{cachingpolicy} = B{0}.
        @rtype: L{Cache}
        i    N(   R   t   cachingpolicyR   R   (   R
   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR   g   s    
(   R   R   R   R!   R   R   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR   9   s   		t   DefinitionsReaderc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sõ   
    The WSDL definitions reader provides an integration
    between the Definitions and the object cache.
    @ivar fn: A factory function (constructor) used to
        create the object not found in the cache.
    @type fn: I{Constructor}
    c         C   s   t  j |  | ƒ | |  _ d S(   sé   
        @param options: An options object.
        @type options: I{Options}
        @param fn: A factory function (constructor) used to
            create the object not found in the cache.
        @type fn: I{Constructor}
        N(   R   R   t   fn(   R
   R   R/   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR   |   s    c         C   s”   |  j  ƒ  } |  j | d ƒ } | j | ƒ } | d k ra |  j | |  j ƒ } | j | | ƒ n/ |  j | _ x  | j D] } |  j | j _ qw W| S(   sÛ  
        Open a WSDL at the specified I{url}.
        First, the WSDL attempted to be retrieved from
        the I{object cache}.  After unpickled from the cache, the
        I{options} attribute is restored.
        If not found, it is downloaded and instantiated using the 
        I{fn} constructor and added to the cache for the next open().
        @param url: A WSDL url.
        @type url: str.
        @return: The WSDL object.
        @rtype: I{Definitions}
        t   wsdlN(	   R   R   R   R   R/   R   R   t   importst   imported(   R
   R   R   R   R    t   imp(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR!   ‡   s    c         C   s'   |  j  j d k r |  j  j St ƒ  Sd S(   sw   
        Get the cache.
        @return: The I{options} when I{cachingpolicy} = B{1}.
        @rtype: L{Cache}
        i   N(   R   R-   R   R   (   R
   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR       s    
(   R   R   R   R   R!   R   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyR.   s   s   		N(    (   R   t   suds.sax.parserR    t   suds.transportR   t
   suds.cacheR   R   t
   suds.storeR   t   suds.pluginR   t   loggingR   R   t   logR   R   R.   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/reader.pyt   <module>   s   :