a
    �ÏOczI  ã                
   @   sf  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 ozdej dd	¡v Zej	 
d¡o’e o’e ZdZejejejgejf  ed
< e d¡Zedœdd„Zdoejeje eje eeejdœdd„Zeedœdd„Zejedœdd„Z G dd„ dej!ƒZ"G dd„ dƒZ#dpejeedœdd„Z$dqejeedœd d!„Z%ejejej dœd"d#„Z&ejejej dœd$d%„Z'ejedœd&d'„Z(ejeeje ed(œd)d*„Z)ejeje eje ed+œd,d-„Z*drejeje eje ejejegef ejejgejej f eeejd.œd/d0„Z+dsejeje eje eejd1œd2d3„Z,dtejeje eje eejd4œd5d6„Z-ejdœd7d8„Z.ejdœd9d:„Z/ejdœd;d<„Z0dueje eje ejd=œd>d?„Z1dveje eje ejd=œd@dA„Z2dweje eje ejd=œdBdC„Z3ej4eej5e6f eeje eje ejdDœdEdF„Z7dxeeeje eje eej8ejef dIœdJdK„Z9G dLdM„ dMƒZ:eedNœdOdP„Z;ejedœdQdR„Z<dyejej eje edSœdTdU„Z=ej	 
d¡�rDe�rDdVdWl>m?Z? edœdXdY„Z@eƒ ZAejBejejf edZ< dzejeje ejdSœd[d
„Zn8edœd\dY„Z@ejeje eje ejej d]œd^d_„Z?ee6d`œdadb„ZCejedœdcdd„ZDejg ejf ejg ejf ejg ejf deœdfdg„ZEeEdhdi„ e1ƒZFeEdjdi„ e2ƒZGeEdkdi„ e3ƒZHe.e/e0dlœZIejJeejg ejf f edm< e1e2e3dlœZKejJeejeje eje gejf f edn< dS ){é    N)ÚWeakKeyDictionaryÚcygwinÚwinZ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   úD/var/www/html/gsl.tools/lib/python3.9/site-packages/click/_compat.pyÚget_filesystem_encoding   s    r   F)ÚstreamÚencodingÚerrorsÚforce_readableÚforce_writabler
   c                 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   )r   r
   c                 C   s,   zt  | ¡jdkW S  ty&   Y dS 0 dS )z$Checks if a given encoding is ascii.ÚasciiFN)ÚcodecsÚlookupÚnameÚLookupError)r   r   r   r   Úis_ascii_encoding-   s    r!   )r   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                	       s\   e Zd Zdejeje eje eeejddœ‡ fdd„Z	ddœdd„Z
edœd	d
„Z‡  ZS )r   FN)r   r   r   r   r   Úextrar
   c                    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__r	   c                 C   s$   z|   ¡  W n ty   Y n0 d S 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)Ú__name__Ú
__module__Ú__qualname__r&   r(   ÚOptionalÚstrÚboolÚAnyr,   r3   r4   Ú__classcell__r   r   r.   r   r   =   s     úør   c                   @   sr   e Zd ZdZdejeedœdd„Zeej	dœdd„Z
eed	œd
d„Zedœdd„Zedœdd„Ze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).
    F)r   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   s   t | j|ƒS r   )r"   r*   ©r-   r   r   r   r   Ú__getattr__k   s    z_FixupStream.__getattr__)Úsizer
   c                 C   s2   t | jdd ƒ}|d ur&t t||ƒ¡S | j |¡S )NÚread1)r"   r*   r&   r'   ÚbytesÚread)r-   rB   Úfr   r   r   rC   n   s    z_FixupStream.read1r	   c                 C   sX   | j r
dS t| jdd ƒ}|d ur.t t|ƒ ¡S z| j d¡ W n tyR   Y dS 0 dS )NTÚreadabler   F)r=   r"   r*   r&   r'   r:   rE   r1   ©r-   Úxr   r   r   rG   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 n: tyx   z| j d¡ W n tyr   Y Y dS 0 Y n0 dS )NTÚwritabler   ó    F)r>   r"   r*   r&   r'   r:   Úwriter1   rH   r   r   r   rJ   ‚   s    z_FixupStream.writablec                 C   sT   t | jdd ƒ}|d ur$t t|ƒ ¡S z| j | j ¡ ¡ W n tyN   Y dS 0 dS )NÚseekableFT)r"   r*   r&   r'   r:   ÚseekÚtellr1   rH   r   r   r   rM   ‘   s    z_FixupStream.seekableN)FF)r5   r6   r7   Ú__doc__r&   r(   r:   r,   r9   r;   rA   ÚintrD   rC   rG   rJ   rM   r   r   r   r   r)   W   s     üü
r)   )r   Údefaultr
   c                 C   s.   zt |  d¡tƒW S  ty(   | Y S 0 d S ©Nr   )Ú
isinstancerE   rD   r1   ©r   rR   r   r   r   Ú_is_binary_readerœ   s    rV   c                 C   sP   z|   d¡ W n< tyJ   z|   d¡ W Y dS  ty@   Y n0 | Y S 0 dS )NrK   r   FT)rL   r1   rU   r   r   r   Ú_is_binary_writer¥   s    

rW   c                 C   sH   t | dƒrt tj| ¡S t| dd ƒ}|d urDt |dƒrDt tj|¡S d S ©NFÚbufferT)rV   r&   r'   r(   r"   ©r   Úbufr   r   r   Ú_find_binary_reader²   s    
r\   c                 C   sH   t | dƒrt tj| ¡S t| dd ƒ}|d urDt |dƒrDt tj|¡S d S rX   )rW   r&   r'   r(   r"   rZ   r   r   r   Ú_find_binary_writerÄ   s    
r]   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    r_   )r   ÚattrÚvaluer
   c                 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   r`   ra   Zstream_valuer   r   r   Ú_is_compat_stream_attrß   s    rb   )r   r   r   r
   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   )rb   )r   r   r   r   r   r   Ú_is_compatible_text_streamè   s
    ÿ
þrc   )Útext_streamr   r   Ú	is_binaryÚfind_binaryr   r   r
   c           	      C   s~   || dƒrt  t j| ¡}nFt  t j| ¡} t| ||ƒrH|d u rDt| ƒsH| S || ƒ}|d u r\| S |}|d u rld}t|||||d�S )NFr   )r   r   )r&   r'   r(   ÚTextIOrc   r_   r   )	rd   r   r   re   rf   r   r   Zbinary_readerZpossible_binary_readerr   r   r   Ú_force_correct_text_streamó   s,    	
ÿÿûrh   )Útext_readerr   r   r   r
   c                 C   s   t | ||tt|d�S )N©r   )rh   rV   r\   )ri   r   r   r   r   r   r   Ú_force_correct_text_reader!  s    úrk   )Útext_writerr   r   r   r
   c                 C   s   t | ||tt|d�S )N©r   )rh   rW   r]   )rl   r   r   r   r   r   r   Ú_force_correct_text_writer1  s    úrn   c                  C   s   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  s    
rr   c                  C   s   t tjƒ} | d u rtdƒ‚| S )Nz7Was not able to determine binary stream for sys.stdout.)r]   r   Ústdoutrp   ©Úwriterr   r   r   Úget_binary_stdoutH  s    
rv   c                  C   s   t tjƒ} | d u rtdƒ‚| S )Nz7Was not able to determine binary stream for sys.stderr.)r]   r   Ústderrrp   rt   r   r   r   Úget_binary_stderrO  s    
rx   )r   r   r
   c                 C   s,   t tj| |ƒ}|d ur|S ttj| |dd�S )NTrj   )Ú_get_windows_console_streamr   ro   rk   ©r   r   r$   r   r   r   Úget_text_stdinV  s    r{   c                 C   s,   t tj| |ƒ}|d ur|S ttj| |dd�S ©NTrm   )ry   r   rs   rn   rz   r   r   r   Úget_text_stdout_  s    r}   c                 C   s,   t tj| |ƒ}|d ur|S ttj| |dd�S r|   )ry   r   rw   rn   rz   r   r   r   Úget_text_stderrh  s    r~   )ÚfileÚmoder   r   r
   c                 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)Úfilenamer€   r   r   Úatomicr
   c              
      s(  dˆ v }t  | ¡dkrht‡ fdd„dD ƒƒrJ|r:tƒ dfS t||d�dfS |rXtƒ dfS t||d�dfS |s~t| ˆ ||ƒdfS d	ˆ v rŽtd
ƒ‚dˆ v ržtdƒ‚dˆ vr®tdƒ‚dd l	}dd l
}zt  | ¡j}W n tyä   d }Y n0 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 �rJdn|¡}W �qÞW n€ t�yØ } zf|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‚ W Y d }~n
d }~0 0 �q|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>Š  rK   zopen_stream.<locals>.<genexpr>)ÚwÚarI   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.rI   z&Use the `overwrite`-parameter instead.rŽ   z,Atomic writes only make sense with `w`-mode.r   ÚO_BINARYz.__atomic-writel        Z08xi¶  Únt)$ÚosÚfsdecodeÚanyrv   r}   rr   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)r‡   r€   r   r   rˆ   Úbinaryr–   r—   ÚpermÚflagsÚtmp_filenameÚfdÚerF   Úafr   rŒ   r   Úopen_stream~  sh    

ÿ

þ
ÿ
þýü
r²   c                   @   s|   e Zd Zejeeddœdd„Zeedœdd„ƒZde	dd	œd
d„Z
eejdœdd„Zd dœdd„Zdd„ Zedœdd„ZdS )r¨   N)rF   r®   Úreal_filenamer
   c                 C   s   || _ || _|| _d| _d S ©NF)Ú_fÚ_tmp_filenameÚ_real_filenameÚclosed)r-   rF   r®   r³   r   r   r   r,   Ï  s    z_AtomicFile.__init__r	   c                 C   s   | j S r   )r·   r2   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·   )r-   r¹   r   r   r   rº   Ù  s
    
z_AtomicFile.closer?   c                 C   s   t | j|ƒS r   )r"   rµ   r@   r   r   r   rA   à  s    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__æ  s    z_AtomicFile.__exit__c                 C   s
   t | jƒS r   )Úreprrµ   r2   r   r   r   Ú__repr__é  s    z_AtomicFile.__repr__)F)r5   r6   r7   r&   rª   r9   r,   Úpropertyr   r:   rº   r;   rA   r»   r¿   rÁ   r   r   r   r   r¨   Î  s   r¨   )ra   r
   c                 C   s   t  d| ¡S )Nr   )Ú_ansi_reÚsub)ra   r   r   r   Ú
strip_ansií  s    rÅ   c                 C   s$   t | ttfƒr| j} q | jj d¡S )Nz
ipykernel.)rT   r)   r   r*   r/   r6   Ú
startswithr^   r   r   r   Ú_is_jupyter_kernel_outputñ  s    rÇ   )r   Úcolorr
   c                 C   s0   |d u r*| d u rt j} t| ƒ o(t| ƒ S | S r   )r   ro   r4   rÇ   )r   rÈ   r   r   r   Úshould_strip_ansiø  s
    rÉ   é   )ry   c                  C   s   dd l } |  ¡ S rS   )ÚlocaleÚgetpreferredencoding)rË   r   r   r   Ú_get_argv_encoding  s    rÍ   Ú_ansi_stream_wrappersc                    s    zt  | ¡}W n ty$   d}Y n0 |dur2|S ddl}t| |ƒ}|j| |d�‰t tjˆj	¡}|j
‰ ‡ ‡fdd„}||_
z|t | < W n tyš   Y n0 |S )zbSupport ANSI color and style codes on Windows by wrapping a
        stream with colorama.
        Nr   )Ústripc                    s,   z
ˆ | ƒW S  t y&   ˆ ¡  ‚ Y n0 d S r   )ÚBaseExceptionÚ	reset_all)Ús©Ú_writeZansi_wrapperr   r   Ú_safe_write$  s
    
z'auto_wrap_for_ansi.<locals>._safe_write)rÎ   Úgetr1   ÚcoloramarÉ   ÚAnsiToWin32r&   r'   rg   r   rL   )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   ro   r   r   r   r   r   rÍ   6  s    )rF   r   r   r
   c                 C   s   d S r   r   )rF   r   r   r   r   r   ry   9  s    ry   )rI   r
   c                 C   s   t t| ƒƒS r   )ÚlenrÅ   )rI   r   r   r   Úterm_len?  s    rÛ   c                 C   s$   z
|   ¡ W S  ty   Y dS 0 d S r´   )r4   r1   r^   r   r   r   r4   C  s    
r4   )Úsrc_funcÚwrapper_funcr
   c                    s"   t ƒ ‰ tjdœ‡ ‡‡fdd„}|S )Nr	   c                     sb   ˆƒ } zˆ   | ¡}W n ty*   d }Y n0 |d ur8|S ˆƒ }z|ˆ | < W n ty\   Y n0 |S r   )rÖ   r1   r#   ©ÚcacherÜ   rÝ   r   r   ÚfuncO  s    
z&_make_cached_stream_func.<locals>.func)r   r&   rg   )rÜ   rÝ   rà   r   rÞ   r   Ú_make_cached_stream_funcJ  s    rá   c                   C   s   t jS r   )r   ro   r   r   r   r   Ú<lambda>a  rK   râ   c                   C   s   t jS r   )r   rs   r   r   r   r   râ   b  rK   c                   C   s   t jS r   )r   rw   r   r   r   r   râ   c  rK   )ro   rs   rw   Úbinary_streamsÚtext_streams)FF)F)F)FF)F)F)NN)NN)NN)r…   Nr†   F)NN)N)Lr   Úior’   Úrer   Útypingr&   Úweakrefr   ÚplatformrÆ   ZCYGWINÚversionZMSYS2ÚenvironrÖ   Z
APP_ENGINEZWINr   r8   ÚCallablerg   Ú__annotations__ÚcompilerÃ   r9   r   r(   r:   r   r!   rª   r   ÚTextIOWrapperr   r)   rV   rW   r\   r]   r_   rb   rc   rh   rk   rn   rr   rv   rx   r{   r}   r~   ÚUnionÚPathLikerQ   r„   ÚTupler²   r¨   rÅ   rÇ   rÉ   Z_winconsolery   rÍ   rÎ   ÚMutableMappingrÛ   r4   rá   Z_default_text_stdinZ_default_text_stdoutZ_default_text_stderrrã   ÚMappingrä   r   r   r   r   Ú<module>   s  
ÿ"
  ûúE		
þ  ùø2 üû üû ÿþ
 ÿþ
 ÿþ
û    ûúP ÿþ ÿþ'
þþý$	ýþ"ÿ