
    )Jf                     l    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dZ G d d	e          Zd
 ZdS )zXRI resolution.
    )	urlencode)fetchers)etxrd)toURINormal)iterServiceszhttp://proxy.xri.net/c                   *    e Zd ZdZefdZddZd ZdS )ProxyResolverz5Python interface to a remote XRI proxy resolver.
    c                     || _         d S N)	proxy_url)selfr   s     V/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/openid/yadis/xrires.py__init__zProxyResolver.__init__   s    "    Nc                     t          |          dd         }| j        |z   }ddi}|r||d<   n|dxx         dz  cc<   t          ||          }|S )aQ  Build a URL to query the proxy resolver.

        @param xri: An XRI to resolve.
        @type xri: unicode

        @param service_type: The service type to resolve, if you desire
            service endpoint selection.  A service type is a URI.
        @type service_type: str

        @returns: a URL
        @returntype: str
           N_xrd_rzapplication/xrds+xml_xrd_tz
;sep=false)r   r   _appendArgs)r   xriservice_typeqxrihxriargsquerys          r   queryURLzProxyResolver.queryURL   sv      3#~$ ,
  	+)DNN NNNl*NNND$''r   c                 B   g }d}|D ]}|                      ||          }t          j        |          }|j        dvr6t	          j        |j                  }t	          j        ||          }t          t          |                    }	|
                    |	           ||fS )a  Resolve some services for an XRI.

        Note: I don't implement any service endpoint selection beyond what
        the resolver I'm querying does, so the Services I return may well
        include Services that were not of the types you asked for.

        May raise fetchers.HTTPFetchingError or L{etxrd.XRDSError} if
        the fetching or parsing don't go so well.

        @param xri: An XRI to resolve.
        @type xri: unicode

        @param service_types: A list of services types to query for.  Service
            types are URIs.
        @type service_types: list of str

        @returns: tuple of (CanonicalID, Service elements)
        @returntype: (unicode, list of C{ElementTree.Element}s)
        N)      )r   r   fetchstatusr   	parseXRDSbodygetCanonicalIDlistr   extend)
r   r   service_typesservicescanonicalIDr   urlresponseetsome_servicess
             r   r   zProxyResolver.query6   s    * 
 ) 
	+ 
	+L--\22C~c**Hj00 //B.sB77K b!1!122MOOM****
 H$$r   r   )__name__
__module____qualname____doc__DEFAULT_PROXYr   r   r    r   r   r	   r	      s[          "/ # # # #   B+% +% +% +% +%r   r	   c                    t          |d          r5t          |                                          }|                                 t	          |          dk    r| S d|                     d          v rd}nd}| |t          |          S )z,Append some arguments to an HTTP query.
    itemsr   ?&)hasattrr%   r5   sortlenrstripr   )r*   r   seps      r   r   r   d   s     tW DJJLL!!		
4yyA~~
 cjjoosCC411r   N)r1   urllib.parser   openidr   openid.yadisr   openid.yadis.xrir   openid.yadis.servicesr   r2   objectr	   r   r3   r   r   <module>rC      s     # " " " " "             ( ( ( ( ( ( . . . . . .'S% S% S% S% S%F S% S% S%l2 2 2 2 2r   