
    qh                         / S Qr SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
Jr   " S S\5      r " S S	\5      rS
 rS rg))discoverDiscoveryResultDiscoveryFailure    )StringIO)fetchers)YADIS_HEADER_NAMEYADIS_CONTENT_TYPEYADIS_ACCEPT_HEADER)MetaNotFoundfindHTMLMetac                   "    \ rS rSrSrSrS rSrg)r      zBRaised when a YADIS protocol error occurs in the discovery processNc                 :    [         R                  X5        X l        g )N)	Exception__init__http_response)selfmessager   s      G/var/www/html/env/lib/python3.13/site-packages/openid/yadis/discover.pyr   DiscoveryFailure.__init__   s    4)*    )r   )__name__
__module____qualname____firstlineno____doc__identity_urlr   __static_attributes__ r   r   r   r      s    LL+r   r   c                   >    \ rS rSrSrSrSrSrSrSr	S r
S rS rSrg)r      z:Contains the result of performing Yadis discovery on a URINc                     Xl         g)zWInitialize the state of the object

sets all attributes to None except the request_uri
Nrequest_uri)r   r$   s     r   r   DiscoveryResult.__init__)   s
    
 'r   c                 P    U R                   c  gU R                  U R                   :g  $ )z*Was the Yadis protocol's indirection used?F)xrds_urinormalized_urir   s    r   usedYadisLocation!DiscoveryResult.usedYadisLocation0   s$    == ""dmm33r   c                 V    U R                  5       =(       d    U R                  [        :H  $ )z5Is the response text supposed to be an XRDS document?)r*   content_typer	   r)   s    r   isXRDSDiscoveryResult.isXRDS6   s'    &&( 8!!%77	9r   r#   )r   r   r   r   r   r$   r(   r'   r-   response_textr   r*   r.   r   r   r   r   r   r      s7    D K N H L M'49r   r   c                    [        U 5      n[        R                  " U S[        0S9nUR                  S;  a  [        SUR                  < 3U5      eUR                  Ul        UR                  R                  S5      Ul
        [        U5      Ul        UR                  (       a  UR                  5       (       a}  [        R                  " UR                  5      nUR                  S;  a-  [        SUR                  < 3U5      nUR                  Ul        UeUR                  R                  S5      Ul
        UR                  Ul        U$ )a  Discover services for a given URI.

@param uri: The identity URI as a well-formed http or https
    URI. The well-formedness and the protocol are not checked, but
    the results of this function are undefined if those properties
    do not hold.

@return: DiscoveryResult object

@raises Exception: Any exception that can be raised by fetching a URL with
    the given fetcher.
@raises DiscoveryFailure: When the HTTP response does not have a 200 code.
Accept)headers)      zCHTTP Response status from identity URL host is not 200. Got status content-typez<HTTP Response status from Yadis host is not 200. Got status )r   r   fetchr
   statusr   	final_urlr(   r3   getr-   whereIsYadisr'   r*   r   bodyr0   )uriresultrespexcs       r   r   r   <   s    S!F>>#2E'FGD{{*$#{{./35 	5
 !NNF ,,**>:F"4(FO63355~~foo.;;j("#';;2379C  &44CI"ll..~>99FMr   c                    U R                   R                  S5      nU(       a7  UR                  SS5      S   R                  5       [        :X  a  U R
                  $ U R                   R                  [        R                  " 5       5      nU(       d  U=(       d    SnUR                  SS5      n[        U5      S:X  aN  US   R                  5       R                  S5      (       a'  US   R                  SS5      S   R                  5       nOS	n[        U R                  [        5      (       a   U R                  R                  U5      nOU R                  n [!        [#        U5      5      nU$ U$ ! [         aL     U R                  R                  S	5      n NA! [         a     U R                  R                  US
5      n  Njf = ff = f! [$        [        4 a     U$ f = f)zGiven a HTTPResponse, return the location of the Yadis document.

May be the URL just retrieved, another URL, or None if no suitable URL can
be found.

[non-blocking]

@returns: str or None
r6   ;   r       zcharset==zutf-8replace)r3   r:   splitlowerr	   r9   r   rsplitlenstrip
startswith
isinstancer<   bytesdecodeUnicodeErrorr   r   r   )r?   r-   	yadis_locencodingcontents        r   r;   r;   h   s    <<##N3L 	sA&q)//15GG~~ LL$$%6%<%<%>?	 (-2L#**32HH"QK%%'22:>>#A;,,S!4Q7==?"$))U++H"ii..x8G ))('):;	 y/ $ HH"&))"2"27";' H #'))"2"28Y"GHH$ !,/  s<   +E, G ,
G7F&F>:G=F>>GGGN)__all__ior   openidr   openid.yadis.constantsr   r	   r
   openid.yadis.parsehtmlr   r   r   r   objectr   r   r;   r   r   r   <module>r[      sD   
=  @ @ =+y +#9f #9L)XAr   