
    df                         d Z ddlZddlZddlZddlZddlZg dZ G d de          ZddZ	ddZ
dd	ZddZd Z	 ddlZej        ej        f e	ZdS # eef$ r 	 ddlZe
ZY dS # e$ r eZY Y dS w xY ww xY w)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                       e Zd ZdS )r   N)__name__
__module____qualname__       /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/getpass.pyr   r      s          r   r   
Password: c                    d}t          j                    5 }	 t          j        dt          j        t          j        z            }t          j        |d          }|                    |           t          j	        |          }|                    |           |s|}n# t          $ rz |                                 	 t          j                                        }n)# t          t           f$ r d}t#          | |          }Y nw xY wt          j        }|st          j        }Y nw xY w|.	 t'          j        |          }|dd         }|dxx         t&          j         z  cc<   t&          j        }	t/          t&          d          r|	t&          j        z  }		 t'          j        ||	|           t5          | ||          }t'          j        ||	|           |                                 n/# t'          j        ||	|           |                                 w xY wn@# t&          j        $ r. | ||ur|                                 t#          | |          }Y nw xY w|                    d           |cddd           S # 1 swxY w Y   dS )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_getpassr9      s    F				 15	$RYr{%:;;B)B%%C$$$$S))E&&&  
	$ 
	$ 
	$KKMMM:Y%%''"J/ : : :)&&99: IE $
	$ >:'++!!!fA7<-'")"37J// 8#w'77O#%b/3???'eDDDF%b/3???LLNNNN %b/3???LLNNNNN= 
: 
: 
:%  &&KKMMM)&&99
: 	Tc1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   I7BBI7D ;CD #D =D ?D  D I7D  I7'A)H(G$9+H$,HHI7:II7II77I;>I;c                 f   t           j        t           j        urt          | |          S | D ]}t	          j        |           d}	 t	          j                    }|dk    s|dk    rn$|dk    rt          |dk    r|dd         }n||z   }Dt	          j        d           t	          j        d           |S )	z:Prompt for password with echo off, using Windows getwch().    r   N)r   r    	__stdin__r$   msvcrtputwchgetwchKeyboardInterrupt)r0   r1   cpws       r   win_getpassrH   a   s    
y%%///  a	B	MOO99T		;;##99CRCBBaB	 M$
M$Ir   c                     t          j        dt          d           |st          j        }t          d|           t          | |          S )Nz%Can not control echo on the terminal.   )
stacklevelz&Warning: Password input may be echoed.)file)warningswarnr   r   r%   printr,   )r0   r1   s     r   r$   r$   x   sV    M9>        	
2@@@@ff%%%r   r;   c                    |st           j        }|st           j        }t          |           } | r	 |                    |            nZ# t
          $ rM |                     |j        d          } |                     |j                  } |                    |            Y nw xY w|	                                 |
                                }|st          |d         dk    r
|d d         }|S )Nreplacer@   r   )r   r%   r    strr/   UnicodeEncodeErrorencodeencodingdecoder-   readlineEOFError)r0   r1   r   lines       r   r,   r,      s      	[[F 	!LL    ! 	! 	! 	!]]6?I>>F]]6?33FLL     		!
 	>>D Bx4CRCyKs   A ABBc                      dD ]'} t           j                            |           }|r|c S (ddl}|                    t          j                              d         S )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.

    )LOGNAMEUSERLNAMEUSERNAMEr   N)r   environgetpwdgetpwuidgetuid)nameuserra   s      r   r   r      sd     9  z~~d## 	KKK	 JJJ<<	$$Q''r   )r   N)r;   NN)__doc__r   r   r   r   rM   __all__UserWarningr   r9   rH   r$   r,   r   r&   r'   r+   r   ImportErrorr"   rB   r
   r   r   <module>rj      s_  
 
      				 				 



 
0
0
0 ( ' ' ' '[ ' ' 'A A A AH   .& & & &   2( ( ($NNN w((( GGG 	^$      # # #"#s/   A A4A$A4$A0+A4/A00A4