
    /dw                     T    d Z ddlmZ ddlmZ ddlmZ  G d dej                  ZdS )	zV
Keyring Chainer - iterates over other viable backends to
discover passwords in each.
   )backend)
properties   )failc                   n    e Zd ZdZdZej        d             Zej        d             Zd Z	d Z
d Zd Zd	S )
ChainerBackendzZ
    >>> ChainerBackend()
    <keyring.backends.chainer.ChainerBackend object at ...>
    Tc                 ^    t          | j                  dk    rdnt          j        j        dz
  S )z
        If there are backends to chain, high priority
        Otherwise very low priority since our operation when empty
        is the same as null.
        r   
   )lenbackendsr   Keyringpriority)clss    8lib/python3.11/site-packages/keyring/backends/chainer.pyr   zChainerBackend.priority   s,     &&*Krr1F1JK    c                     d }t          |t          j                              }t          |t          j        d          S )z5
        Discover all keyrings for chaining.
        c                     t           j        pt          }t          | t                     o ||           o
| j        dk    S )N    )r   _limitbool
isinstancer   r   )keyringlimits     r   allowz&ChainerBackend.backends.<locals>.allow$   sC    N*dEw777 )E'NN)$q(r   T)keyreverse)filterr   get_all_keyringsortedby_priority)r   r   alloweds      r   r   zChainerBackend.backends   sC    	 	 	  7 9 9::g7#6EEEEr   c                 R    | j         D ]}|                    ||          }||c S d S N)r   get_password)selfserviceusernamer   passwords        r   r$   zChainerBackend.get_password/   sH    } 	  	 G++GX>>H   	  	 r   c                 l    | j         D ]+}	 |                    |||          c S # t          $ r Y (w xY wd S r#   )r   set_passwordNotImplementedError)r%   r&   r'   r(   r   s        r   r*   zChainerBackend.set_password5   s`    } 	 	G++GXxHHHHH&   	 	s   $
11c                 j    | j         D ]*}	 |                    ||          c S # t          $ r Y 'w xY wd S r#   )r   delete_passwordr+   )r%   r&   r'   r   s       r   r-   zChainerBackend.delete_password<   s^    } 	 	G..wAAAAA&   	 	s   #
00c                 R    | j         D ]}|                    ||          }||c S d S r#   )r   get_credential)r%   r&   r'   r   
credentials        r   r/   zChainerBackend.get_credentialC   sK    } 	" 	"G //BBJ "!!!!"	" 	"r   N)__name__
__module____qualname____doc__viabler   classpropertyr   r   r$   r*   r-   r/    r   r   r   r      s          FL L L F F F          " " " " "r   r   N)r4    r   _compatr   r   KeyringBackendr   r7   r   r   <module>r;      s~    
                        <" <" <" <" <"W+ <" <" <" <" <"r   