o
    ­+ca~I  ã                   @   s  U d dl 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 ej	 
d¡Zej	 
d¡o/dejv Zdejv o=dej dd	¡v Zej	 
d¡oIe oIe ZdZejejejgejf  ed
< e d¡Zdefdd„Z		dtdejdeje deje dededejfdd„Zdedefdd„Zdejdefdd„Z G dd„ dej!ƒZ"G dd„ dƒZ#dudejdedefd d!„Z$dudejdedefd"d#„Z%dejdejej fd$d%„Z&dejdejej fd&d'„Z'dejdefd(d)„Z(dejd*ed+eje defd,d-„Z)dejdeje deje defd.d/„Z*		dtd0ejdeje deje d1ejejegef d2ejejgejej f dededejfd3d4„Z+	dud5ejdeje deje dedejf
d6d7„Z,	dud8ejdeje deje dedejf
d9d:„Z-dejfd;d<„Z.dejfd=d>„Z/dejfd?d@„Z0	dvdeje deje dejfdAdB„Z1	dvdeje deje dejfdCdD„Z2	dvdeje deje dejfdEdF„Z3dGej4eej5e6f dHedeje deje dejf
dIdJ„Z7	K		L	dwdMedHedeje deje dNedej8ejef fdOdP„Z9G dQdR„ dRƒZ:d+edefdSdT„Z;dejdefdUdV„Z<	dvdejej dWeje defdXdY„Z=ej	 
d¡�rie�ridZd[l>m?Z? defd\d]„Z@eƒ ZAejBejejf ed^< 	dxdejdWeje dejfd_d
„Zndefd`d]„Z@daejdeje deje dejej fdbdc„Z?ddede6fdedf„ZCdejdefdgdh„ZDdiejg ejf djejg ejf dejg ejf fdkdl„ZEeEdmdn„ e1ƒZFeEdodn„ e2ƒZGeEdpdn„ e3ƒZHe.e/e0dqœZIejJeejg ejf f edr< e1e2e3dqœZKejJeejeje eje gejf f eds< dS )yé    N)ÚWeakKeyDictionaryÚcygwinÚwinÚGCCÚAPPENGINE_RUNTIMEzDevelopment/ÚSERVER_SOFTWAREÚ Úauto_wrap_for_ansiz\033\[[;?0-9]*[a-zA-Z]Úreturnc                   C   s   t  ¡ pt  ¡ S ©N)ÚsysÚgetfilesystemencodingÚgetdefaultencoding© r   r   ú//usr/lib/python3/dist-packages/click/_compat.pyÚget_filesystem_encoding   s   r   FÚstreamÚencodingÚerrorsÚforce_readableÚforce_writablec                 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   r   r   Ú_make_text_stream   s   úr   c                 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!   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)Úgetattrr   r   r!   ©r   Úrvr   r   r   r   5   s   r   c                       sh   e Zd Z		ddejdeje deje dededejdd	f‡ fd
d„Z	ddd„Z
defdd„Z‡  ZS )r   Fr   r   r   r   r   Úextrar
   Nc                    s8   t  t jt|||ƒ¡ | _}tƒ j|||fi |¤Ž d S r   )ÚtÚcastÚBinaryIOÚ_FixupStreamÚ_streamÚsuperÚ__init__)Úselfr   r   r   r   r   r%   ©Ú	__class__r   r   r,   >   s   	
ÿz!_NonClosingTextIOWrapper.__init__c                 C   s$   z|   ¡  W d S  ty   Y d S w r   )ÚdetachÚ	Exception©r-   r   r   r   Ú__del__L   s
   ÿz _NonClosingTextIOWrapper.__del__c                 C   s
   | j  ¡ S r   )r*   Úisattyr2   r   r   r   r4   R   s   
z_NonClosingTextIOWrapper.isatty©FF)r
   N)Ú__name__Ú
__module__Ú__qualname__r&   r(   ÚOptionalÚstrÚboolÚAnyr,   r3   r4   Ú__classcell__r   r   r.   r   r   =   s(    úþýüûúùø
r   c                   @   s~   e Zd ZdZ		ddejdedefdd„Zded	ej	fd
d„Z
ded	efdd„Zd	efdd„Zd	efdd„Zd	ef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   c                 C   s   || _ || _|| _d S r   )r*   Ú_force_readableÚ_force_writable)r-   r   r   r   r   r   r   r,   a   s   
z_FixupStream.__init__r   r
   c                 C   ó   t | j|ƒS r   )r"   r*   ©r-   r   r   r   r   Ú__getattr__k   ó   z_FixupStream.__getattr__Úsizec                 C   s2   t | jdd ƒ}|d urt t||ƒ¡S | j |¡S )NÚread1)r"   r*   r&   r'   ÚbytesÚread)r-   rD   Úfr   r   r   rE   n   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;   rG   r1   ©r-   Úxr   r   r   rI   v   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Úwritabler   ó    F)r?   r"   r*   r&   r'   r;   Úwriter1   rJ   r   r   r   rL   ‚   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Útellr1   rJ   r   r   r   rO   ‘   s   þÿz_FixupStream.seekableNr5   )r6   r7   r8   Ú__doc__r&   r(   r;   r,   r:   r<   rB   ÚintrF   rE   rI   rL   rO   r   r   r   r   r)   W   s     üþý
ü
r)   Údefaultc                 C   s*   z	t |  d¡tƒW S  ty   | Y S w ©Nr   )Ú
isinstancerG   rF   r1   ©r   rT   r   r   r   Ú_is_binary_readerœ   s
   ÿrX   c                 C   sL   z|   d¡ W dS  ty%   z	|   d¡ W Y dS  ty$   Y | Y S w w )NrM   r   FT)rN   r1   rW   r   r   r   Ú_is_binary_writer¥   s   ù
þürY   c                 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)rX   r&   r'   r(   r"   ©r   Úbufr   r   r   Ú_find_binary_reader²   ó   
r_   c                 C   rZ   r[   )rY   r&   r'   r(   r"   r]   r   r   r   Ú_find_binary_writerÄ   r`   ra   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Ö   s   rc   Ú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   rd   re   Ústream_valuer   r   r   Ú_is_compat_stream_attrß   s   rg   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   )rg   )r   r   r   r   r   r   Ú_is_compatible_text_streamè   s
   ÿ
þrh   Útext_streamÚ	is_binaryÚfind_binaryc           	      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(   ÚTextIOrh   rc   r   )	ri   r   r   rj   rk   r   r   Úbinary_readerÚpossible_binary_readerr   r   r   Ú_force_correct_text_streamó   s&   
	ûro   Útext_readerc                 C   ó   t | ||tt|d�S )N©r   )ro   rX   r_   )rp   r   r   r   r   r   r   Ú_force_correct_text_reader!  ó   úrs   Útext_writerc                 C   rq   )N©r   )ro   rY   ra   )ru   r   r   r   r   r   r   Ú_force_correct_text_writer1  rt   rw   c                  C   ó   t tjƒ} | d u rtdƒ‚| S )Nz6Was not able to determine binary stream for sys.stdin.)r_   r   ÚstdinÚRuntimeError)Úreaderr   r   r   Úget_binary_stdinA  ó   
r|   c                  C   rx   )Nz7Was not able to determine binary stream for sys.stdout.)ra   r   Ústdoutrz   ©Úwriterr   r   r   Úget_binary_stdoutH  r}   r�   c                  C   rx   )Nz7Was not able to determine binary stream for sys.stderr.)ra   r   Ústderrrz   r   r   r   r   Úget_binary_stderrO  r}   rƒ   c                 C   ó,   t tj| |ƒ}|d ur|S ttj| |dd�S )NTrr   )Ú_get_windows_console_streamr   ry   rs   ©r   r   r$   r   r   r   Úget_text_stdinV  ó   r‡   c                 C   r„   ©NTrv   )r…   r   r~   rw   r†   r   r   r   Úget_text_stdout_  rˆ   rŠ   c                 C   r„   r‰   )r…   r   r‚   rw   r†   r   r   r   Úget_text_stderrh  rˆ   r‹   ÚfileÚ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_openq  s   
r‘   ÚrÚstrictÚfilenameÚatomicc              
      sú  dˆ v }| dkr1t ‡ fdd„dD ƒƒr"|rtƒ dfS t||d�dfS |r)tƒ dfS t||d�dfS |s<t| ˆ ||ƒdfS d	ˆ v rDtd
ƒ‚dˆ v rLtdƒ‚dˆ vrTtdƒ‚dd l}dd l}zt	 
| ¡j}W n tyo   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"|¡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ÚarK   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.rK   z&Use the `overwrite`-parameter instead.r›   z,Atomic writes only make sense with `w`-mode.r   ÚO_BINARYz.__atomic-writel        Ú08xi¶  Únt)#Úanyr�   rŠ   r|   r‡   r‘   Ú
ValueErrorÚerrnoÚrandomÚosÚ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)r”   r�   r   r   r•   Úbinaryr¢   r£   ÚpermÚflagsÚtmp_filenameÚfdÚerH   Úafr   r™   r   Úopen_stream~  sl   

ÿÿ
þ
ÿþ€ø
r¿   c                   @   s‚   e Zd Zdejdededdfdd„Zedefdd	„ƒZdde	ddfdd„Z
dedejfdd„Zddd„Zdd„ Zdefdd„ZdS )rµ   rH   r»   Úreal_filenamer
   Nc                 C   s   || _ || _|| _d| _d S ©NF)Ú_fÚ_tmp_filenameÚ_real_filenameÚclosed)r-   rH   r»   rÀ   r   r   r   r,   Ï  s   
z_AtomicFile.__init__c                 C   s   | j S r   )rÄ   r2   r   r   r   r   Õ  s   z_AtomicFile.nameFÚdeletec                 C   s.   | j rd S | j ¡  t | j| j¡ d| _ d S )NT)rÅ   rÂ   Úcloser¤   r   rÃ   rÄ   )r-   rÆ   r   r   r   rÇ   Ù  s
   

z_AtomicFile.closer   c                 C   r@   r   )r"   rÂ   rA   r   r   r   rB   à  rC   z_AtomicFile.__getattr__c                 C   s   | S r   r   r2   r   r   r   Ú	__enter__ã  s   z_AtomicFile.__enter__c                 C   s   | j |d ud� d S )N)rÆ   )rÇ   )r-   Úexc_typeÚ	exc_valueÚtbr   r   r   Ú__exit__æ  ó   z_AtomicFile.__exit__c                 C   s
   t | jƒS r   )ÚreprrÂ   r2   r   r   r   Ú__repr__é  s   
z_AtomicFile.__repr__©F)r
   rµ   )r6   r7   r8   r&   r·   r:   r,   Úpropertyr   r;   rÇ   r<   rB   rÈ   rÌ   rÏ   r   r   r   r   rµ   Î  s    
rµ   c                 C   s   t  d| ¡S )Nr   )Ú_ansi_reÚsub)re   r   r   r   Ú
strip_ansií  rC   rÔ   c                 C   s0   t | ttfƒr| j} t | ttfƒs| jj d¡S )Nz
ipykernel.)rV   r)   r   r*   r/   r7   Ú
startswithrb   r   r   r   Ú_is_jupyter_kernel_outputñ  s   ÿrÖ   Úcolorc                 C   s0   |d u r| d u rt j} t| ƒ ot| ƒ S | S r   )r   ry   r4   rÖ   )r   r×   r   r   r   Úshould_strip_ansiø  s
   rØ   é   )r…   c                  C   s   dd l } |  ¡ S rU   )ÚlocaleÚgetpreferredencoding)rÚ   r   r   r   Ú_get_argv_encoding  s   rÜ   Ú_ansi_stream_wrappersc                    s    zt  | ¡}W n ty   d}Y nw |dur|S ddl}t| |ƒ}|j| |d�‰t tjˆj	¡}|j
‰ ‡ ‡fdd„}||_
z|t | < W |S  tyO   Y |S w )zbSupport ANSI color and style codes on Windows by wrapping a
        stream with colorama.
        Nr   )Ústripc                    s$   zˆ | ƒW S  t y   ˆ ¡  ‚ w r   )ÚBaseExceptionÚ	reset_all)Ús©Ú_writeÚansi_wrapperr   r   Ú_safe_write$  s   
þz'auto_wrap_for_ansi.<locals>._safe_write)rÝ   Úgetr1   ÚcoloramarØ   ÚAnsiToWin32r&   r'   rl   r   rN   )r   r×   Úcachedrç   rÞ   r$   rå   r   râ   r   r	     s*   ÿ

ýýc                   C   s   t tjdd ƒp	tƒ S )Nr   )r"   r   ry   r   r   r   r   r   rÜ   7  rÍ   rH   c                 C   s   d S r   r   )rH   r   r   r   r   r   r…   :  s   r…   rK   c                 C   s   t t| ƒƒS r   )ÚlenrÔ   )rK   r   r   r   Úterm_len@  rC   rë   c                 C   s    z|   ¡ W S  ty   Y dS w rÁ   )r4   r1   rb   r   r   r   r4   D  s
   
ÿr4   Úsrc_funcÚwrapper_funcc                    s"   t ƒ ‰ dtjf‡ ‡‡fdd„}|S )Nr
   c                     sb   ˆƒ } zˆ   | ¡}W n ty   d }Y nw |d ur|S ˆƒ }z|ˆ | < W |S  ty0   Y |S w r   )ræ   r1   r#   ©Úcacherì   rí   r   r   ÚfuncP  s    ÿ
þþz&_make_cached_stream_func.<locals>.func)r   r&   rl   )rì   rí   rð   r   rî   r   Ú_make_cached_stream_funcK  s   rñ   c                   C   ó   t jS r   )r   ry   r   r   r   r   Ú<lambda>b  ó    ró   c                   C   rò   r   )r   r~   r   r   r   r   ró   c  rô   c                   C   rò   r   )r   r‚   r   r   r   r   ró   d  rô   )ry   r~   r‚   Úbinary_streamsÚtext_streamsr5   rÐ   )NN)r’   Nr“   Fr   )Lr   Úior¤   Úrer   Útypingr&   Úweakrefr   ÚplatformrÕ   ÚCYGWINÚversionÚMSYS2Úenvironræ   Ú
APP_ENGINEÚWINr	   r9   ÚCallablerl   Ú__annotations__ÚcompilerÒ   r:   r   r(   r;   r   r!   r·   r   ÚTextIOWrapperr   r)   rX   rY   r_   ra   rc   rg   rh   ro   rs   rw   r|   r�   rƒ   r‡   rŠ   r‹   ÚUnionÚPathLikerS   r‘   ÚTupler¿   rµ   rÔ   rÖ   rØ   Ú_winconsoler…   rÜ   rÝ   ÚMutableMappingrë   r4   rñ   Ú_default_text_stdinÚ_default_text_stdoutÚ_default_text_stderrrõ   ÚMappingrö   r   r   r   r   Ú<module>   s˜  
 ÿ"
ûÿþýüû
úE	"		ÿÿÿ
þùÿþýüûúù
ø2üÿþýü
ûüÿþýü
ûÿÿÿ
þ
ÿÿÿ
þ
ÿÿÿ
þ	ÿþýü
ûûÿþýüû
úPÿ
ÿÿ
þÿÿÿþ(ÿÿÿ

þÿÿ
þ$ý	ýþ"ÿ