\dfdZddlZddlZddlZddlZddlZgdZGddeZd dZ d dZ d d Z dd Z d Z ddlZejejfe ZdS#eef$r ddlZe ZYdS#e$re ZYYdSwxYwwxYw)aUtilities to get a password and/or the current user name. getpass(prompt[, stream]) - Prompt for a password, with echo turned off. getuser() - Get the user name from the environment or password database. GetPassWarning - This UserWarning is issued when getpass() cannot prevent echoing of the password contents while reading. On Windows, the msvcrt module will be used. N)getpassgetuserGetPassWarningceZdZdS)rN)__name__ __module__ __qualname__..\python\lib\getpass.pyrrsr r Password: cd}tj5} tjdtjtjz}t j|d}||t j |}|||s|}n#t$rz|  tj }n)#tt f$rd}t#||}YnwxYwtj }|s tj}YnwxYw|. t'j|}|dd}|dxxt&jzcc<t&j} t/t&dr| t&jz} t'j|| |t5|||}t'j|| ||n/#t'j|| ||wxYwn@#t&j$r.|||ur| t#||}YnwxYw|d|cdddS#1swxYwYdS)aPrompt for a password, with echo turned off. Args: prompt: Written on stream to ask for the input. Default: 'Password: ' stream: A writable file object to display the prompt. Defaults to the tty. If no tty is available defaults to sys.stderr. Returns: The seKr3t input. Raises: EOFError: If our input tty or stdin was closed. GetPassWarning: When we were unable to turn echo off on the input. Always restores terminal settings before returning. Nz/dev/ttyzw+TCSASOFT)input ) contextlib ExitStackosopenO_RDWRO_NOCTTYioFileIO enter_context TextIOWrapperOSErrorclosesysstdinfilenoAttributeError ValueErrorfallback_getpassstderrtermios tcgetattrECHO TCSAFLUSHhasattrr tcsetattr _raw_inputflusherrorwrite) promptstreampasswdstackfdttyroldnewtcsetattr_flagss r unix_getpassr9sF    15 $RYr{%:;;B)B%%C    $ $ $$S))E    & & &  $ $ $ KKMMM :Y%%''"J/ : : :)&&99 :IE $ $ > :'++!!!fA7<-'")"37J//8#w'77O#%b/3???'eDDDF%b/3???LLNNNN%b/3???LLNNNNN= : : :%&&KKMMM)&&99 :  Tc111111111111111111sI7BBI7D ;CD #D=D ?DD I7D  I7'A)H(G$9+H$,HHI7:II7II77I;>I;cftjtjurt||S|D]}t j|d} t j}|dks|dkrn$|dkrt|dkr |dd}n||z}Dt jdt jd|S) z:Prompt for password with echo off, using Windows getwch(). rN)rr __stdin__r$msvcrtputwchgetwchKeyboardInterrupt)r0r1cpws r win_getpassrHas y %%///  a B  MOO 99T  ;;# # 99CRCBBaB  M$ M$ Ir ctjdtd|s tj}t d|t ||S)Nz%Can not control echo on the terminal.) stacklevelz&Warning: Password input may be echoed.)file)warningswarnrrr%printr,)r0r1s r r$r$xsV M9>     2@@@@ ff % %%r r;c|s tj}|s tj}t|}|r ||nZ#t $rM||jd}||j}||YnwxYw| | }|st|ddkr |dd}|S)Nreplacer@r) rr%r strr/UnicodeEncodeErrorencodeencodingdecoder-readlineEOFError)r0r1rlines r r,r,s    [[F  ! LL ! ! ! !]]6?I>>F]]6?33F LL  !   >>  D  Bx4CRCy KsAABBcdD]'}tj|}|r|cS(ddl}|tjdS)zGet 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. )LOGNAMEUSERLNAMEUSERNAMErN)renvirongetpwdgetpwuidgetuid)nameuserras r rrsd9z~~d##  KKK JJJ << $ $Q ''r )r N)r;NN)__doc__rrrrrM__all__ UserWarningrr9rHr$r,rr&r'r+r ImportErrorr"rBr r r rjs_     0 0 0(''''['''AAAAH.&&&&2((($ NNN w(((GGG ^$  ###"#s/AA4A$A4$A0+A4/A00A4