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   úH/var/www/html/chatgpt/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   Zstream_valuer   r   r   Ú_is_compat_stream_attrÝ   s   rk   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   )rk   )r   r
   r   r   r   r   Ú_is_compatible_text_streamæ   s
   ÿ
þrl   Ú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,   ÚTextIOrl   rg   r   )	rm   r
   r   rn   rp   r   r   Zbinary_readerZpossible_binary_readerr   r   r   Ú_force_correct_text_streamñ   s&   
	ûrs   Útext_readerc                 C  ó   t | ||tt|d�S )N©r   )rs   rZ   rc   )rt   r
   r   r   r   r   r   Ú_force_correct_text_reader  ó   úrw   Útext_writerc                 C  ru   )N©r   )rs   r\   re   )ry   r
   r   r   r   r   r   Ú_force_correct_text_writer/  rx   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 )NTrv   )Ú_get_windows_console_streamr"   r}   rw   ©r
   r   r%   r   r   r   Úget_text_stdinT  ó   r‹   c                 C  rˆ   ©NTrz   )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   )rm   r    r
   r   r   r   rn   ro   rp   rq   r   r   r   r   r   r   )
rt   r    r
   r   r   r   r   r   r   r   )
ry   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ÚabcZcabcÚior§   Úrer"   Útypingr*   Útypesr   Úweakrefr   Úplatformrâ   ZCYGWINZWINÚcompilerß   r   r   r   ÚTextIOWrapperr   r-   rZ   r\   rc   re   rg   rk   rl   rs   rw   r{   r€   r…   r‡   r‹   rŽ   r�   r–   rÉ   r¾   rá   rã   rè   Z_winconsoler‰   rì   rð   r8   rù   Z_default_text_stdinZ_default_text_stdoutZ_default_text_stderrrý   Ú__annotations__rþ   r   r   r   r   Ú<module>   sŒ    
û

E	



	
	ù2üü



ûQ
$
ÿ




ýý