
    e                     V    d Z ddlmZ ddlmZ ddlmZ  G d dej                        Zy)	zV
Keyring Chainer - iterates over other viable backends to
discover passwords in each.
   )backend)
properties   )failc                   z    e Zd ZdZdZej                  defd       Zej                  d        Z	d Z
d Zd Zd	 Zy
)ChainerBackendzZ
    >>> ChainerBackend()
    <keyring.backends.chainer.ChainerBackend object at ...>
    Treturnc                 p    t        | j                        dkD  rdS 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    :/usr/lib/python3/dist-packages/keyring/backends/chainer.pyr   zChainerBackend.priority   s.     &*rK1F1F1JK    c                 |    d }t        |t        j                               }t        |t        j                  d      S )z5
        Discover all keyrings for chaining.
        c                     t         j                  xs t        }t        | t               xr  ||       xr | j
                  dkD  S )N    )r   _limitbool
isinstancer   r   )keyringlimits     r   allowz&ChainerBackend.backends.<locals>.allow$   sA    NN*dEw77 )'N)$$q(r   T)keyreverse)filterr   get_all_keyringsortedby_priority)r   r   alloweds      r   r   zChainerBackend.backends   s3    	  7 7 9:g7#6#6EEr   c                 V    | j                   D ]  }|j                  ||      }||c S  y N)r   get_password)selfserviceusernamer   passwords        r   r%   zChainerBackend.get_password/   s2    }} 	 G++GX>H#	 r   c                 n    | j                   D ]  }	 |j                  |||      c S  y # t        $ r Y &w xY wr$   )r   set_passwordNotImplementedError)r&   r'   r(   r)   r   s        r   r+   zChainerBackend.set_password5   sC    }} 	G++GXxHH	 ' s   (	44c                 l    | j                   D ]  }	 |j                  ||      c S  y # t        $ r Y %w xY wr$   )r   delete_passwordr,   )r&   r'   r(   r   s       r   r.   zChainerBackend.delete_password<   sA    }} 	G..wAA	 ' s   '	33c                 V    | j                   D ]  }|j                  ||      }||c S  y r$   )r   get_credential)r&   r'   r(   r   
credentials        r   r0   zChainerBackend.get_credentialC   s3    }} 	"G //BJ%!!	"r   N)__name__
__module____qualname____doc__viabler   classpropertyfloatr   r   r%   r+   r.   r0    r   r   r   r      s`     FL L L F F  "r   r   N)r5    r   _compatr   r   KeyringBackendr   r9   r   r   <module>r=      s'   
    <"W++ <"r   