
    qh                     0     " S  S\ 5      r " S S\ 5      rg)c                   H    \ 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)YadisServiceManager   zHolds the state of a list of selected Yadis services, managing
storing it in a session and iterating over the services in order.c                 V    Xl         X l        [        U5      U l        X@l        S U l        g N)starting_url	yadis_urllistservicessession_key_current)selfr   r   r
   r   s        F/var/www/html/env/lib/python3.13/site-packages/openid/yadis/manager.py__init__YadisServiceManager.__init__   s+    ( # X&     c                 ,    [        U R                  5      $ )z!How many untried services remain?)lenr
   r   s    r   __len__YadisServiceManager.__len__   s    4==!!r   c                     U $ r    r   s    r   __iter__YadisServiceManager.__iter__   s    r   c                      U R                   R                  S5      U l        U R                  $ ! [         a    [        ef = f)zpReturn the next service

self.current() will continue to return that service until the
next call to this method.    )r
   popr   
IndexErrorStopIterationr   s    r   __next__YadisServiceManager.__next__   s@    
	! MM--a0DM ==   	 	 s    . ?c                     U R                   $ )zIReturn the current service.

Returns None if there are no services left.
r   r   s    r   currentYadisServiceManager.current'   s    
 }}r   c                 6    XR                   U R                  4;   $ r   )r   r   )r   urls     r   forURLYadisServiceManager.forURL.   s    (($..999r   c                     U R                   SL$ )z$Has the first service been returned?Nr#   r   s    r   startedYadisServiceManager.started1   s    }}D((r   c                      XU R                   '   g)z5Store this object in the session, by its session key.N)r   )r   sessions     r   storeYadisServiceManager.store5   s    $(  !r   )r   r
   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r    r$   r(   r+   r/   __static_attributes__r   r   r   r   r      s0    I"
!:))r   r   c                   ^    \ rS rSrSrSrSrSS jrS rSS jr	S	 r
SS
 jrSS jrSS jrSrg)	Discovery:   a7  State management for discovery.

High-level usage pattern is to call .getNextService(discover) in
order to find the next available service for this user for this
session. Once a request completes, call .finish() to clean up the
session state.

@ivar session: a dict-like object that stores state unique to the
    requesting user-agent. This object must be able to store
    serializable objects.

@ivar url: the URL that is used to make the discovery request

@ivar session_key_suffix: The suffix that will be used to identify
    this object in the session object.
auth_yadis_services_Nc                 F    Xl         X l        Uc  U R                  nX0l        g)zInitialize a discovery objectN)r.   r'   DEFAULT_SUFFIXsession_key_suffix)r   r.   r'   r>   s       r   r   Discovery.__init__O   s$    %!%!4!4"4r   c                    U R                  5       nUb  U(       d  U R                  5         U(       d%  U" U R                  5      u  p4U R                  XC5      nU(       a(  [	        U5      nUR                  U R                  5        U$ SnU$ )a
  Return the next authentication service for the pair of
user_input and session.  This function handles fallback.


@param discover: a callable that takes a URL and returns a
    list of services

@type discover: str -> [service]


@return: the next available service
N)
getManagerdestroyManagerr'   createManagernextr/   r.   )r   discovermanagerr   r
   services         r   getNextServiceDiscovery.getNextServiceX   sw     //#w!"*488"4I((=G7mGMM$,,'  Gr   c                 p    U R                  US9nUb!  UR                  5       nU R                  US9  U$ SnU$ )a<  Clean up Yadis-related services in the session and return
the most-recently-attempted service from the manager, if one
exists.

@param force: True if the manager should be deleted regardless
of whether it's a manager for self.url.

@return: current service endpoint object or None if there is
    no current service
forceN)rA   r$   rB   )r   rL   rF   rG   s       r   cleanupDiscovery.cleanupu   sJ     ///.oo'Ge,  Gr   c                 4    U R                   U R                  -   $ )z[Get the session key for this starting URL and suffix

@return: The session key
@rtype: str
)PREFIXr>   r   s    r   getSessionKeyDiscovery.getSessionKey   s     {{T4444r   c                     U R                   R                  U R                  5       5      nUb)  UR                  U R                  5      (       d  U(       a  U$ g)a  Extract the YadisServiceManager for this object's URL and
suffix from the session.

@param force: True if the manager should be returned
regardless of whether it's a manager for self.url.

@return: The current YadisServiceManager, if it's for this
    URL, or else None
N)r.   getrQ   r(   r'   )r   rL   rF   s      r   rA   Discovery.getManager   sC     ,,""4#5#5#78W^^DHH%=%=Nr   c                     U R                  5       nU R                  5       (       a  [        SU< SU R                  < 35      eU(       d  g[	        U R                  X!U5      nUR                  U R                  5        U$ )zCreate a new YadisService Manager for this starting URL and
suffix, and store it in the session.

@raises KeyError: When I already have a manager.

@return: A new YadisServiceManager or None
zThere is already a z manager for N)rQ   rA   KeyErrorr'   r   r/   r.   )r   r
   r   keyrF   s        r   rC   Discovery.createManager   si       "??+ , , %dhh	SIdll#r   c                 `    U R                  US9b  U R                  5       nU R                  U	 gg)a$  Delete any YadisServiceManager with this starting URL and
suffix from the session.

If there is no service manager or the service manager is for a
different URL, it silently does nothing.

@param force: True if the manager should be deleted regardless
of whether it's a manager for self.url.
rK   N)rA   rQ   r.   )r   rL   rX   s      r   rB   Discovery.destroyManager   s4     ???'3$$&CS! 4r   )r.   r>   r'   r   )F)r1   r2   r3   r4   r5   r=   rP   r   rH   rM   rQ   rA   rC   rB   r6   r   r   r   r8   r8   :   s6    " NF5:,5 ("r   r8   N)objectr   r8   r   r   r   <module>r]      s    6)& 6)rI" I"r   