o
    ßý°jF  ã                   @  s~  U d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dl	Z	d dl
Zd dlmZ d dlmZ e	j d¡Ze	j d¡Ze d¡Z		d€d�dd„Zd‚dd„Zdƒdd„ZG dd„ dejƒZG dd„ dƒZd„d…d d!„Zd„d…d"d#„Zd†d%d&„Zd†d'd(„Zd‡d)d*„Z dˆd-d.„Z!d‰d/d0„Z"		d€dŠd6d7„Z#	d„d‹d9d:„Z$	d„dŒd<d=„Z%d�d>d?„Z&d�d@dA„Z'd�dBdC„Z(dŽd�dDdE„Z)dŽd�dFdG„Z*dŽd�dHdI„Z+d�dMdN„Z,	O		P	d‘d’dUdV„Z-G dWdX„ dXƒZ.d“dYdZ„Z/d”d[d\„Z0	dŽd•d`da„Z1e	j d¡rûerûdbdcl2m3Z3 d–ddde„Z4n
d–dfde„Z4d—didj„Z3d˜dmdn„Z5d”dodp„Z6d™dudv„Z7e7dwdx„ e)ƒZ8e7dydx„ e*ƒZ9e7dzdx„ e+ƒZ:e&e'e(d{œZ;d|e<d}< e)e*e+d{œZ=d~e<d< dS )šé    )ÚannotationsN)ÚTracebackType©ÚWeakKeyDictionaryÚcygwinÚwinz\033\[[0-?]*[ -/]*[@-~]FÚstreamú
t.BinaryIOÚencodingú
str | NoneÚerrorsÚforce_readableÚboolÚforce_writableÚreturnút.TextIOc                 C  s0   |d u rt | ƒ}|d u rd}t| ||d||d�S )NÚreplaceT)Úline_bufferingr   r   )Úget_best_encodingÚ_NonClosingTextIOWrapper)r   r
   r   r   r   © r   ú€/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/click/_compat.pyÚ_make_text_stream   s   úr   Ústrc                 C  s(   z	t  | ¡jdkW S  ty   Y dS w )z$Checks if a given encoding is ascii.ÚasciiF)ÚcodecsÚlookupÚnameÚLookupError)r
   r   r   r   Úis_ascii_encoding+   s
   ÿr   út.IO[t.Any]c                 C  s$   t | ddƒp	t ¡ }t|ƒrdS |S )z1Returns the default stream encoding if not found.r
   Nzutf-8)ÚgetattrÚsysÚgetdefaultencodingr   ©r   Úrvr   r   r   r   3   s   r   c                      s8   e Zd Z		dd‡ fdd„Zddd„Zddd„Z‡  ZS )r   Fr   r	   r
   r   r   r   r   r   Úextraút.Anyr   ÚNonec                   s8   t  t jt|||ƒ¡ | _}tƒ j|||fi |¤Ž d S ©N)ÚtÚcastÚBinaryIOÚ_FixupStreamÚ_streamÚsuperÚ__init__)Úselfr   r
   r   r   r   r&   ©Ú	__class__r   r   r0   <   s   	
ÿz!_NonClosingTextIOWrapper.__init__c                 C  s$   z|   ¡  W d S  ty   Y d S w r)   )ÚdetachÚ	Exception©r1   r   r   r   Ú__del__J   s
   ÿz _NonClosingTextIOWrapper.__del__c                 C  s
   | j  ¡ S r)   )r.   Úisattyr6   r   r   r   r8   P   s   
z_NonClosingTextIOWrapper.isatty©FF)r   r	   r
   r   r   r   r   r   r   r   r&   r'   r   r(   )r   r(   ©r   r   )Ú__name__Ú
__module__Ú__qualname__r0   r7   r8   Ú__classcell__r   r   r2   r   r   ;   s    ú
r   c                   @  sR   e Zd ZdZ		dddd	„Zddd„Zddd„Zd dd„Zd dd„Zd dd„Z	dS )!r-   aQ  The new io interface needs more from streams than streams
    traditionally implement.  As such, this fix-up code is necessary in
    some circumstances.

    The forcing of readable and writable flags are there because some tools
    put badly patched objects on sys (one such offender are certain version
    of jupyter notebook).
    Fr   r	   r   r   r   c                 C  s   || _ || _|| _d S r)   )r.   Ú_force_readableÚ_force_writable)r1   r   r   r   r   r   r   r0   _   s   
z_FixupStream.__init__r   r   r   r'   c                 C  ó   t | j|ƒS r)   )r!   r.   ©r1   r   r   r   r   Ú__getattr__i   ó   z_FixupStream.__getattr__ÚsizeÚintÚbytesc                 C  s2   t | jdd ƒ}|d urt t||ƒ¡S | j |¡S )NÚread1)r!   r.   r*   r+   rG   Úread)r1   rE   Úfr   r   r   rH   l   s   z_FixupStream.read1c                 C  sV   | j rdS t| jdd ƒ}|d urt t|ƒ ¡S z	| j d¡ W dS  ty*   Y dS w )NTÚreadabler   F)r?   r!   r.   r*   r+   r   rI   r5   ©r1   Úxr   r   r   rK   t   s   þÿz_FixupStream.readablec                 C  s|   | j rdS t| jdd ƒ}|d urt t|ƒ ¡S z	| j d¡ W dS  ty=   z
| j d¡ W Y dS  ty<   Y Y dS w w )NTÚwritableó    F)r@   r!   r.   r*   r+   r   Úwriter5   rL   r   r   r   rN   €   s    ûþÿýz_FixupStream.writablec                 C  sR   t | jdd ƒ}|d urt t|ƒ ¡S z| j | j ¡ ¡ W dS  ty(   Y dS w )NÚseekableFT)r!   r.   r*   r+   r   ÚseekÚtellr5   rL   r   r   r   rQ   �   s   þÿz_FixupStream.seekableNr9   )r   r	   r   r   r   r   ©r   r   r   r'   )rE   rF   r   rG   r:   )
r;   r<   r=   Ú__doc__r0   rC   rH   rK   rN   rQ   r   r   r   r   r-   U   s    ü




r-   Údefaultc                 C  s*   z	t |  d¡tƒW S  ty   | Y S w ©Nr   )Ú
isinstancerI   rG   r5   ©r   rV   r   r   r   Ú_is_binary_readerš   s
   ÿrZ   c                 C  sL   z|   d¡ W dS  ty%   z	|   d¡ W Y dS  ty$   Y | Y S w w )NrO   Ú FT)rP   r5   rY   r   r   r   Ú_is_binary_writer£   s   ù
þür\   út.BinaryIO | Nonec                 C  óH   t | dƒrt tj| ¡S t| dd ƒ}|d ur"t |dƒr"t tj|¡S d S ©NFÚbufferT)rZ   r*   r+   r,   r!   ©r   Úbufr   r   r   Ú_find_binary_reader°   ó   
rc   c                 C  r^   r_   )r\   r*   r+   r,   r!   ra   r   r   r   Ú_find_binary_writerÂ   rd   re   c                 C  s   t t| ddƒpdƒS )z3A stream is misconfigured if its encoding is ASCII.r
   Nr   )r   r!   ©r   r   r   r   Ú_stream_is_misconfiguredÔ   ó   rg   ÚattrÚvaluec                 C  s$   t | |dƒ}||kp|du o|duS )zŽA stream attribute is compatible if it is equal to the
    desired value or the desired value is unset and the attribute
    has a value.
    N)r!   )r   ri   rj   Ústream_valuer   r   r   Ú_is_compat_stream_attrÝ   s   rl   c                 C  s   t | d|ƒot | d|ƒS )zcCheck if a stream's encoding and errors attributes are
    compatible with the desired values.
    r
   r   )rl   )r   r
   r   r   r   r   Ú_is_compatible_text_streamæ   s
   ÿ
þrm   Útext_streamÚ	is_binaryú%t.Callable[[t.IO[t.Any], bool], bool]Úfind_binaryú,t.Callable[[t.IO[t.Any]], t.BinaryIO | None]c           	      C  s~   || dƒrt  t j| ¡}n#t  t j| ¡} t| ||ƒr$|d u r"t| ƒs$| S || ƒ}|d u r.| S |}|d u r6d}t|||||d�S )NFr   )r   r   )r*   r+   r,   ÚTextIOrm   rg   r   )	rn   r
   r   ro   rq   r   r   Úbinary_readerÚpossible_binary_readerr   r   r   Ú_force_correct_text_streamñ   s&   
	ûrv   Útext_readerc                 C  ó   t | ||tt|d�S )N©r   )rv   rZ   rc   )rw   r
   r   r   r   r   r   Ú_force_correct_text_reader  ó   úrz   Útext_writerc                 C  rx   )N©r   )rv   r\   re   )r|   r
   r   r   r   r   r   Ú_force_correct_text_writer/  r{   r~   c                  C  ó   t tjƒ} | d u rtdƒ‚| S )Nz6Was not able to determine binary stream for sys.stdin.)rc   r"   ÚstdinÚRuntimeError)Úreaderr   r   r   Úget_binary_stdin?  ó   
rƒ   c                  C  r   )Nz7Was not able to determine binary stream for sys.stdout.)re   r"   Ústdoutr�   ©Úwriterr   r   r   Úget_binary_stdoutF  r„   rˆ   c                  C  r   )Nz7Was not able to determine binary stream for sys.stderr.)re   r"   Ústderrr�   r†   r   r   r   Úget_binary_stderrM  r„   rŠ   c                 C  ó,   t tj| |ƒ}|d ur|S ttj| |dd�S )NTry   )Ú_get_windows_console_streamr"   r€   rz   ©r
   r   r%   r   r   r   Úget_text_stdinT  ó   rŽ   c                 C  r‹   ©NTr}   )rŒ   r"   r…   r~   r�   r   r   r   Úget_text_stdout[  r�   r‘   c                 C  r‹   r�   )rŒ   r"   r‰   r~   r�   r   r   r   Úget_text_stderrb  r�   r’   Úfileústr | os.PathLike[str] | intÚmodec                 C  s"   d|v r	t | |ƒS t | |||d�S )z?Handles not passing ``encoding`` and ``errors`` in binary mode.Úb©r
   r   )Úopen)r“   r•   r
   r   r   r   r   Ú_wrap_io_openi  s   
r™   ÚrÚstrictÚfilenameústr | os.PathLike[str]Úatomicútuple[t.IO[t.Any], bool]c              
     s  dˆ v }t  | ¡} t  | ¡dkr9t‡ fdd„dD ƒƒr*|r"tƒ dfS t||d�dfS |r1tƒ dfS t||d�dfS |sDt| ˆ ||ƒdfS d	ˆ v rLt	d
ƒ‚dˆ v rTt	dƒ‚dˆ vr\t	dƒ‚dd l
}dd l}zt  | ¡j}W n tyw   d }Y nw t jt jB t jB }	|r‹|	tt ddƒO }		 t j t j | ¡d| d¡d›�¡}
zt  |
|	|d u r©dn|¡}W n3 tyà } z'|j
|jksÕt jdkrÛ|j
|jkrÛt j |j¡rÛt  |jt j¡rÛW Y d }~q‹‚ d }~ww |d urët  |
|¡ t|ˆ ||ƒ}t ||
t j !| ¡ƒ}t" #t"j$t"j% |¡dfS )Nr–   ú-c                 3  s   � | ]}|ˆ v V  qd S r)   r   )Ú.0Úm©r•   r   r   Ú	<genexpr>ƒ  s   € zopen_stream.<locals>.<genexpr>)ÚwÚarM   Fr—   Tr¦   zÏAppending to an existing file is not supported, because that would involve an expensive `copy`-operation to a temporary file. Open the file in normal `w`-mode and copy explicitly if that's what you're after.rM   z&Use the `overwrite`-parameter instead.r¥   z,Atomic writes only make sense with `w`-mode.r   ÚO_BINARYz.__atomic-writel        Ú08xi¶  Únt)&ÚosÚfspathÚfsdecodeÚanyrˆ   r‘   rƒ   rŽ   r™   Ú
ValueErrorÚerrnoÚrandomÚstatÚst_modeÚOSErrorÚO_RDWRÚO_CREATÚO_EXCLr!   ÚpathÚjoinÚdirnameÚ	randranger˜   ÚEEXISTr   ÚEACCESÚisdirrœ   ÚaccessÚW_OKÚchmodÚ_AtomicFileÚrealpathr*   r+   ÚIOÚAny)rœ   r•   r
   r   rž   Úbinaryr¯   r°   ÚpermÚflagsÚtmp_filenameÚfdÚerJ   Úafr   r£   r   Úopen_streamv  sn   


ÿÿ
þ
ÿþ€ø
rÌ   c                   @  sX   e Zd Zd"dd	„Zed#d
d„ƒZd$d%dd„Zd&dd„Zd'dd„Zd(dd„Z	d#dd „Z
d!S ))rÁ   rJ   r    rÈ   r   Úreal_filenamer   r(   c                 C  s   || _ || _|| _d| _d S ©NF)Ú_fÚ_tmp_filenameÚ_real_filenameÚclosed)r1   rJ   rÈ   rÍ   r   r   r   r0   È  s   
z_AtomicFile.__init__c                 C  s   | j S r)   )rÑ   r6   r   r   r   r   Î  s   z_AtomicFile.nameFÚdeleter   c                 C  s.   | j rd S | j ¡  t | j| j¡ d| _ d S )NT)rÒ   rÏ   Úcloserª   r   rÐ   rÑ   )r1   rÓ   r   r   r   rÔ   Ò  s
   

z_AtomicFile.closer   r'   c                 C  rA   r)   )r!   rÏ   rB   r   r   r   rC   Ù  rD   z_AtomicFile.__getattr__c                 C  s   | S r)   r   r6   r   r   r   Ú	__enter__Ü  s   z_AtomicFile.__enter__Úexc_typeútype[BaseException] | NoneÚ	exc_valueúBaseException | NoneÚtbúTracebackType | Nonec                 C  s   | j |d ud� d S )N)rÓ   )rÔ   )r1   rÖ   rØ   rÚ   r   r   r   Ú__exit__ß  rh   z_AtomicFile.__exit__c                 C  s
   t | jƒS r)   )ÚreprrÏ   r6   r   r   r   Ú__repr__ç  s   
z_AtomicFile.__repr__N)rJ   r    rÈ   r   rÍ   r   r   r(   ©r   r   ©F)rÓ   r   r   r(   rT   )r   rÁ   )rÖ   r×   rØ   rÙ   rÚ   rÛ   r   r(   )r;   r<   r=   r0   Úpropertyr   rÔ   rC   rÕ   rÜ   rÞ   r   r   r   r   rÁ   Ç  s    



rÁ   c                 C  s   t  d| ¡S )Nr[   )Ú_ansi_reÚsub)rj   r   r   r   Ú
strip_ansië  rD   rä   c                 C  s0   t | ttfƒr| j} t | ttfƒs| jj d¡S )Nz
ipykernel.)rX   r-   r   r.   r3   r<   Ú
startswithrf   r   r   r   Ú_is_jupyter_kernel_outputï  s   ÿræ   út.IO[t.Any] | NoneÚcolorúbool | Nonec                 C  s@   |d u r| d u rt j} nt| dƒrdS t| ƒ ot| ƒ S | S )Nrè   F)r"   r€   Úhasattrr8   ræ   )r   rè   r   r   r   Úshould_strip_ansiö  s   
rë   é   )rŒ   c                  C  s   dd l } |  ¡ S rW   )ÚlocaleÚgetpreferredencoding)rí   r   r   r   Ú_get_argv_encoding  s   rï   c                   C  s   t tjdd ƒp
t ¡ S )Nr
   )r!   r"   r€   Úgetfilesystemencodingr   r   r   r   rï     s   rJ   út.TextIO | Nonec                 C  s   d S r)   r   )rJ   r
   r   r   r   r   rŒ     s   rŒ   rM   rF   c                 C  s   t t| ƒƒS r)   )Úlenrä   )rM   r   r   r   Úterm_len  rD   ró   c                 C  s    z|   ¡ W S  ty   Y dS w rÎ   )r8   r5   rf   r   r   r   r8     s
   
ÿr8   Úsrc_funcút.Callable[[], t.TextIO | None]Úwrapper_funcút.Callable[[], t.TextIO]c                   s   t ƒ ‰ d‡ ‡‡fdd„}|S )Nr   rñ   c                    sn   ˆƒ } | d u r	d S zˆ   | ¡}W n ty   d }Y nw |d ur"|S ˆƒ }z|ˆ | < W |S  ty6   Y |S w r)   )Úgetr5   r$   ©Úcacherô   rö   r   r   Úfunc)  s$   ÿ
þþz&_make_cached_stream_func.<locals>.func)r   rñ   r   )rô   rö   rû   r   rù   r   Ú_make_cached_stream_func#  s   rü   c                   C  ó   t jS r)   )r"   r€   r   r   r   r   Ú<lambda>?  ó    rþ   c                   C  rý   r)   )r"   r…   r   r   r   r   rþ   @  rÿ   c                   C  rý   r)   )r"   r‰   r   r   r   r   rþ   A  rÿ   )r€   r…   r‰   z-cabc.Mapping[str, t.Callable[[], t.BinaryIO]]Úbinary_streamszAcabc.Mapping[str, t.Callable[[str | None, str | None], t.TextIO]]Útext_streamsr9   )r   r	   r
   r   r   r   r   r   r   r   r   r   )r
   r   r   r   )r   r    r   r   rà   )r   r    rV   r   r   r   )r   r    r   r]   )r   r   r   r   )r   r   ri   r   rj   r   r   r   )r   r   r
   r   r   r   r   r   )rn   r    r
   r   r   r   ro   rp   rq   rr   r   r   r   r   r   r   )
rw   r    r
   r   r   r   r   r   r   r   )
r|   r    r
   r   r   r   r   r   r   r   )r   r	   )NN)r
   r   r   r   r   r   )
r“   r”   r•   r   r
   r   r   r   r   r    )rš   Nr›   F)rœ   r�   r•   r   r
   r   r   r   rž   r   r   rŸ   )rj   r   r   r   )r   r    r   r   )r   rç   rè   ré   r   r   rß   )rJ   r   r
   r   r   r   r   rñ   )rM   r   r   rF   )rô   rõ   rö   r÷   r   rõ   )>Ú
__future__r   r   Úcollections.abcÚabcÚcabcÚiorª   Úrer"   Útypingr*   Útypesr   Úweakrefr   Úplatformrå   ÚCYGWINÚWINÚcompilerâ   r   r   r   ÚTextIOWrapperr   r-   rZ   r\   rc   re   rg   rl   rm   rv   rz   r~   rƒ   rˆ   rŠ   rŽ   r‘   r’   r™   rÌ   rÁ   rä   ræ   rë   Ú_winconsolerŒ   rï   ró   r8   rü   Ú_default_text_stdinÚ_default_text_stdoutÚ_default_text_stderrr   Ú__annotations__r  r   r   r   r   Ú<module>   sŒ    
û

E	



	
	ù2üü



ûQ
$
ÿ




ýý