ó
Š9Nc           @   s   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d   Z d   Z d d  Z	 e
 d k r e j e	    n  d S(   s@   Simple command line interface to get/set password from a keyringi˙˙˙˙Nc         C   s   t  j  |   S(   sY   Ask for a password to the user.

    This mostly exists to ease the testing process.
    (   t   getpass(   t   prompt(    (    s/   /usr/lib/python2.7/dist-packages/keyring/cli.pyt   input_password   s    c         C   s	   |  GHd S(   sZ   Output the password to the user.

    This mostly exists to ease the testing process.
    N(    (   t   password(    (    s/   /usr/lib/python2.7/dist-packages/keyring/cli.pyt   output_password   s    c   
   	   C   sĆ  t  j d d  } | j d d d d d d d d	 | j d
 d d d d d d d |  d k rr t j d }  n  | j |   \ } } y | \ } } } Wn> t k
 rÚ t |  d k rĘ | j	   d S| j
 d  n X| j d k	 r@y, t j j | j | j  } t j |  Wq@t k
 r<} | j
 d |  q@Xn  | d k r|t j | |  }	 |	 d k rnd St |	  d S| d k rľt d | | f  }	 t j | | |	  d S| j
 d  d S(   s   Main command line interface.t   usages    %prog [get|set] SERVICE USERNAMEs   -ps   --keyring-patht   destt   keyring_patht   defaultt   helps   Path to the keyring backends   -bs   --keyring-backendt   keyring_backends   Name of the keyring backendi   i    s   Wrong number of argumentss$   Unable to load specified keyring: %st   gett   sets   Password for '%s' in '%s': s'   You can only 'get' or 'set' a password.N(   t   optparset   OptionParsert
   add_optiont   Nonet   syst   argvt
   parse_argst
   ValueErrort   lent
   print_helpt   errorR
   t   keyringt   coret   load_keyringR   t   set_keyringt	   Exceptiont   get_passwordR   R   t   set_password(
   R   t   parsert   optst   argst   kindt   servicet   usernamet   backendt   eR   (    (    s/   /usr/lib/python2.7/dist-packages/keyring/cli.pyt   main   sB    

t   __main__(   t   __doc__R    R   R   R   t   keyring.coreR   R   R   R'   t   __name__t   exit(    (    (    s/   /usr/lib/python2.7/dist-packages/keyring/cli.pyt   <module>   s   				7