�
��c@sdZddkZddgZddd�Zddd�Zddd�Zd dd
�Zd�Zy ddk Z e i
e ifWn{ee
fj
oiyddkZWnIej
o=yddklZWnej
o
eZq�eZqXeZnXeZdS(
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�Ntgetpasstgetusers
Password: cCs�|djo
ti}nytii�}Wnt|�SnXti|�}|}|dti@|d<z)ti |ti
|�t||�}Wdti |ti
|�X|id�|S(s�Prompt for a password, with echo turned off.
The prompt is written on stream, by default stdout.
Restore terminal settings at end.
iNs
(
tNonetsyststdouttstdintfilenotdefault_getpassttermiost tcgetattrtECHOt tcsetattrt TCSADRAINt
_raw_inputtwrite(tprompttstreamtfdtoldtnewtpasswd((s/sys/lib/python/getpass.pytunix_getpasss
cCs�titij ot||�Snddk}x|D]}|i|�q7Wd}xj|i�}|djp
|djoPn|djo
t�n|djo|d }qW||}qW|id�|id�|S(s9Prompt for password with echo off, using Windows getch().i�Nts
s
ss(RRt __stdin__RtmsvcrttputchtgetchtKeyboardInterrupt(RRRtctpw((s/sys/lib/python/getpass.pytwin_getpass.s&
cCstidIJt||�S(Ns7Warning: Problem with getpass. Passwords may be echoed.(RtstderrR
(RR((s/sys/lib/python/getpass.pyREs
RcCs�|djo
ti}nt|�}|o|i|�ntii�}|p
t�n|ddjo|d }n|S(Ni�s
(RRRtstrRRtreadlinetEOFError(RRtline((s/sys/lib/python/getpass.pyR
Js
cCsaddk}x/dD]'}|ii|�}|o|SqqWddk}|i|i��dS( 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�NtLOGNAMEtUSERtLNAMEtUSERNAMEi(R$R%R&R'(tostenvirontgettpwdtgetpwuidtgetuid(R(tnametuserR+((s/sys/lib/python/getpass.pyRZs(tAskPassword(t__doc__Rt__all__RRRRR
RRR RtImportErrortAttributeErrorRtEasyDialogsR0R(((s/sys/lib/python/getpass.pys<module> s*
|