łň
\Kc           @   s  d  Z  d d k Z d d g Z d d d  Z d d d  Z d d d  Z d	 d d
  Z d   Z y  d d k	 Z	 e	 i
 e	 i f Wn{ e e f j
 oi y d d k Z WnI e j
 o= y d d k l Z Wn e j
 o e Z qü Xe Z qXe Z n Xe Z d S(   s)  Utilities to get a password and/or the current user name.

getpass(prompt) - prompt for a password, with echo turned off
getuser() - get the user name from the environment or password database

On Windows, the msvcrt module will be used.
On the Mac EasyDialogs.AskPassword is used, if available.

i˙˙˙˙Nt   getpasst   getusers
   Password: c         C   sÁ   | d j o t i } n y t i i   } Wn t |   Sn Xt i |  } | } | d t i @| d <z) t i	 | t i
 |  t |  |  } Wd t i	 | t i
 |  X| i d  | S(   s   Prompt for a password, with echo turned off.
    The prompt is written on stream, by default stdout.

    Restore terminal settings at end.
    i   Ns   
(   t   Nonet   syst   stdoutt   stdint   filenot   default_getpasst   termiost	   tcgetattrt   ECHOt	   tcsetattrt	   TCSADRAINt
   _raw_inputt   write(   t   promptt   streamt   fdt   oldt   newt   passwd(    (    s   /usr/lib/python2.5/getpass.pyt   unix_getpass   s    c         C   sß   t  i t  i j	 o t |  |  Sn d d k } x |  D] } | i |  q7 Wd } xj | i   } | d j p | d j o Pn | d j o
 t  n | d j o | d  } qW | | } qW | i d  | i d  | S(   s9   Prompt for password with echo off, using Windows getch().i˙˙˙˙Nt    s   s   
s   s   (   R   R   t	   __stdin__R   t   msvcrtt   putcht   getcht   KeyboardInterrupt(   R   R   R   t   ct   pw(    (    s   /usr/lib/python2.5/getpass.pyt   win_getpass.   s&     
c         C   s   t  i d IJt |  |  S(   Ns7   Warning: Problem with getpass. Passwords may be echoed.(   R   t   stderrR   (   R   R   (    (    s   /usr/lib/python2.5/getpass.pyR   E   s    R   c         C   s   | d  j o t i } n t |   }  |  o | i |   n t i i   } | p
 t  n | d d j o | d  } n | S(   Ni˙˙˙˙s   
(   R   R   R   t   strR   R   t   readlinet   EOFError(   R   R   t   line(    (    s   /usr/lib/python2.5/getpass.pyR   J   s    
c          C   sa   d d k  }  x/ d D]' } |  i i |  } | o | Sq q Wd d k } | i |  i    d S(	   sÂ   Get the username from the environment or password database.

    First try various environment variables, then the password
    database.  This works on Windows as long as USERNAME is set.

    i˙˙˙˙Nt   LOGNAMEt   USERt   LNAMEt   USERNAMEi    (   R$   R%   R&   R'   (   t   ost   environt   gett   pwdt   getpwuidt   getuid(   R(   t   namet   userR+   (    (    s   /usr/lib/python2.5/getpass.pyR   Z   s     (   t   AskPassword(   t   __doc__R   t   __all__R   R   R   R   R   R   R   R	   R   t   ImportErrort   AttributeErrorR   t   EasyDialogsR0   R    (    (    (    s   /usr/lib/python2.5/getpass.pys   <module>	   s*   	