Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/getpass.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@sdZddkZddgZddd�Zddd�Zddd�Zd	dd
�Zd�Zy ddk	Z	e	i
e	ifWn{ee
fj
oiyddkZWnIej
o=yddklZWnej
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: cCs�|djo
ti}nytii�}Wnt|�SnXti|�}|}|dti@|d<z)ti	|ti
|�t||�}Wdti	|ti
|�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.
    iNs
(
tNonetsyststdouttstdintfilenotdefault_getpassttermiost	tcgetattrtECHOt	tcsetattrt	TCSADRAINt
_raw_inputtwrite(tprompttstreamtfdtoldtnewtpasswd((s/sys/lib/python/getpass.pytunix_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*	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.