
    f                     d    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y)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y)ProxyResolverz5Python interface to a remote XRI proxy resolver.
    c                     || _         y N)	proxy_url)selfr   s     N/var/www/cs2snipe.com/venv/lib/python3.12/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   sa      3#~~$ ,
 )DN Nl*ND$'r   c                 @   g }d}|D ]  }| j                  ||      }t        j                  |      }|j                  dvr9t	        j
                  |j                        }t	        j                  ||      }t        t        |            }	|j                  |	        ||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--\2C~~c*Hj0 /B..sB7K b!12MOOM*
	+ H$$r   r   )__name__
__module____qualname____doc__DEFAULT_PROXYr   r   r    r   r   r	   r	      s     "/ #B+%r   r	   c                     t        |d      r)t        |j                               }|j                          t	        |      dk(  r| S d| j                  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   sd     tWDJJL!		
4yA~
 cjjoC411r   N)r1   urllib.parser   openidr   openid.yadisr   openid.yadis.xrir   openid.yadis.servicesr   r2   objectr	   r   r3   r   r   <module>rC      s4    #   ( .'S%F S%l2r   