
    e                     8    d Z ddlZddlmZmZmZ  G d d      Zy)a  
urllib2.HTTPPasswordMgr object using the keyring, for use with the
urllib2.HTTPBasicAuthHandler.

usage:
    import urllib2
    handlers = [urllib2.HTTPBasicAuthHandler(PasswordMgr())]
    urllib2.install_opener(handlers)
    urllib2.urlopen(...)

This will prompt for a password if one is required and isn't already
in the keyring. Then, it adds it to the keyring for subsequent use.
    N   )get_passworddelete_passwordset_passwordc                   $    e Zd Zd Zd Zd Zd Zy)PasswordMgrc                 *    t        j                         S N)getpassgetuser)selfrealmauthuris      ./usr/lib/python3/dist-packages/keyring/http.pyget_usernamezPasswordMgr.get_username   s          c                 B    | j                  ||      }t        |||       y r
   )r   r   )r   r   r   passwordusers        r   add_passwordzPasswordMgr.add_password   s       0UD(+r   c                     | j                  ||      }t        ||      }|/dt               z  }t        j                  |      }t	        |||       ||fS )Nz1password for %(user)s@%(realm)s for %(authuri)s: )r   r   varsr   r   )r   r   r   r   r   prompts         r   find_user_passwordzPasswordMgr.find_user_password   sV      0t,KdfTFv.Hh/X~r   c                 @    | j                  ||      }t        ||       y r
   )r   r   )r   r   r   r   s       r   clear_passwordzPasswordMgr.clear_password%   s      0t$r   N)__name__
__module____qualname__r   r   r   r    r   r   r   r      s    !,%r   r   )__doc__r    r   r   r   r   r    r   r   <module>r#      s     9 9% %r   