
    F\hY                         S r SSKrSSKrSSKrSSKr/ SQr " S S\5      rSS jrSS jr	SS jr
SS	 jrS
 r SSKr\R                  \R                  4  \rg! \\4 a     SSKr\	r g! \ a    \
r  gf = ff = f)a  Utilities 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)getpassgetuserGetPassWarningc                       \ rS rSrSrg)r       N)__name__
__module____qualname____firstlineno____static_attributes__r       /usr/lib/python3.13/getpass.pyr   r      s    4r   r   c                    Sn[         R                  " 5        n [        R                  " S[        R                  [        R
                  -  5      n[        R                  " US5      nUR                  U5        [        R                  " U5      nUR                  U5        U(       d  UnUb   [&        R(                  " U5      nUSS nUS==   [&        R*                  ) -  ss'   [&        R,                  n	[/        [&        S5      (       a  U	[&        R0                  -  n	 [&        R2                  " XIU5        [5        XUS9n[&        R2                  " XIU5        UR7                  5         UR;                  S5        UsSSS5        $ ! [         a~    UR                  5          [        R                  R                  5       nO#! [        [         4 a    Sn[#        X5      n Of = f[        R                  nU(       d  [        R$                  n GN_f = f! [&        R2                  " XIU5        UR7                  5         f = f! [&        R8                   a'    Ub  e XLa  UR                  5         [#        X5      n GNf = f! , (       d  f       g= f)a  Prompt 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/ttyzw+   TCSASOFT)input
)
contextlib	ExitStackosopenO_RDWRO_NOCTTYioFileIOenter_contextTextIOWrapperOSErrorclosesysstdinfilenoAttributeError
ValueErrorfallback_getpassstderrtermios	tcgetattrECHO	TCSAFLUSHhasattrr   	tcsetattr
_raw_inputflusherrorwrite)
promptstreampasswdstackfdttyr   oldnewtcsetattr_flagss
             r   unix_getpassr;      s    F				5	$RYYr{{%:;B))B%C$$$S)E& >:''+!fA7<<-'")"3"37J//#w'7'77O#%%b3?'eDF%%b3?LLN 	Tc 
 	  
	$KKM:YY%%'"J/ :)&9: IIE
	$0 %%b3?LLN== 
:%  &KKM)&9
:I 
 	s   I5BF (I5,A/H7!H='H7$I5 HF:9H:GHG*HI5HI5)H44H777I2.I51I22I55
Jc                 z   [         R                  [         R                  La  [        X5      $ U  H  n[        R
                  " U5        M     Sn [        R                  " 5       nUS:X  d  US:X  a  OUS:X  a  [        eUS:X  a  USS nOX2-   nM@  [        R
                  " S5        [        R
                  " S5        U$ )z:Prompt for password with echo off, using Windows getwch(). r   N)r!   r"   	__stdin__r&   msvcrtputwchgetwchKeyboardInterrupt)r2   r3   cpws       r   win_getpassrI   `   s    
yy%//a 	B
MMO9T	;##9CRBB  MM$
MM$Ir   c                     SS K nUR                  S[        SS9  U(       d  [        R                  n[        SUS9  [        X5      $ )Nr   z%Can not control echo on the terminal.   )
stacklevelz&Warning: Password input may be echoed.)file)warningswarnr   r!   r'   printr.   )r2   r3   rN   s      r   r&   r&   w   s@    MM9>   	
2@f%%r   c                    U(       d  [         R                  nU(       d  [         R                  n[        U 5      n U (       a"   UR	                  U 5        UR                  5         UR                  5       nU(       d  [        eUS   S:X  a  US S nU$ ! [
         aK    U R                  UR                  S5      n U R                  UR                  5      n UR	                  U 5         Nf = f)NreplacerA   r   )r!   r'   r"   strr1   UnicodeEncodeErrorencodeencodingdecoder/   readlineEOFError)r2   r3   r   lines       r   r.   r.      s    		[F	!LL  	>>DBx4CRyK " 	!]]6??I>F]]6??3FLL 		!s   B AC%$C%c                     S H-  n [         R                  R                  U 5      nU(       d  M+  Us  $     SSKnUR	                  [         R
                  " 5       5      S   $ ! [        [        4 a  n[        S5      UeSnAff = f)aM  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.
Any failure to find a username raises OSError.

.. versionchanged:: 3.13
    Previously, various exceptions beyond just :exc:`OSError`
    were raised.
)LOGNAMEUSERLNAMEUSERNAMEr   Nz"No username set in the environment)	r   environgetpwdgetpwuidgetuidImportErrorKeyErrorr   )nameuserrb   es       r   r   r      sr     9zz~~d#4K 9
C||BIIK(++" C:;BCs   *A   B0A<<B)z
Password: N)r=   NN)__doc__r   r   r   r!   __all__UserWarningr   r;   rI   r&   r.   r   r(   r)   r-   r   re   r$   rC   r   r   r   <module>rm      s   
   	 	 

0 ([ 'AH.&2C2 w((( G 	^$    #"#s/   A A:"A*&A:*A62A:5A66A: