o
    q>e8I                     @   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ZdZejejejgejf  ed< edZ		dod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ej defddZG dd dejZG dd dZdpdejej dedefddZdpdejej dedefddZ dejej dejej fddZ!dej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%		dod)ejej d	eje d
eje d*ejejej egef d+ejejej gejej f dededejfd,d-Z&	dpd.ejej d	eje d
eje dedejf
d/d0Z'	dpd1ejej d	eje d
eje dedejf
d2d3Z(dejfd4d5Z)dejfd6d7Z*dejfd8d9Z+	dqd	eje d
eje dejfd:d;Z,	dqd	eje d
eje dejfd<d=Z-	dqd	eje d
eje dejfd>d?Z.d@ej/edAe0f dBed	eje d
eje dejej f
dCdDZ1	E		F	drdGdHdBed	eje d
eje dIedej2ejej ef fdJdKZ3G dLdM dMZ4d$edefdNdOZ5dejej defdPdQZ6	dqdejejej  dReje defdSdTZ7ej	
drlerldUdVl8m9Z9 defdWdXZ:e Z;ej<ejejf edY< 	dsdejdReje dejfdZdZndefd[dXZ:d\ejd	eje d
eje dejej fd]d^Z9d_ede0fd`daZ=dejej defdbdcZ>ddejg ejej f deejg ejf dejg ejej f fdfdgZ?e?dhdi e,Z@e?djdi e-ZAe?dkdi e.ZBe)e*e+dlZCejDeejg ejf f edm< e,e-e.dlZEejDeejeje eje gejf f edn< dS )t    N)WeakKeyDictionarycygwinwinauto_wrap_for_ansiz\033\[[;?0-9]*[a-zA-Z]Fstreamencodingerrorsforce_readableforce_writablereturnc                 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   N/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/click/_compat.py_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)getattrsysgetdefaultencodingr   r   rvr   r   r   r   ,   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 N)tcastBinaryIO_FixupStream_streamsuper__init__)selfr   r   r   r	   r
   r   	__class__r   r   r&   5   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__C   s
   z _NonClosingTextIOWrapper.__del__c                 C   s
   | j  S r   )r$   isattyr,   r   r   r   r.   I   s   
z_NonClosingTextIOWrapper.isattyFF)r   N)__name__
__module____qualname__r    r"   OptionalstrboolAnyr&   r-   r.   __classcell__r   r   r(   r   r   4   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&   X   s   
z_FixupStream.__init__r   r   c                 C      t | j|S r   )r   r$   r'   r   r   r   r   __getattr__b      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'   r>   fr   r   r   r?   e   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)r8   r   r$   r    r!   r5   rA   r+   r'   xr   r   r   rC   m   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)r9   r   r$   r    r!   r5   writer+   rD   r   r   r   rF   y   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!   r5   seektellr+   rD   r   r   r   rJ      s   z_FixupStream.seekableNr/   )r0   r1   r2   __doc__r    r"   r5   r&   r4   r6   r<   intr@   r?   rC   rF   rJ   r   r   r   r   r#   N   s     

r#   defaultc                 C   s*   z	t | dtW S  ty   | Y S w Nr   )
isinstancerA   r@   r+   r   rO   r   r   r   _is_binary_reader   s
   rS   c                 C   sL   z|  d W dS  ty%   z	|  d W Y dS  ty$   Y | Y S w w )NrH   rG   FT)rI   r+   rR   r   r   r   _is_binary_writer   s   
rT   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)rS   r    r!   r"   r   r   bufr   r   r   _find_binary_reader      
rZ   c                 C   rU   rV   )rT   r    r!   r"   r   rX   r   r   r   _find_binary_writer   r[   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^   attrvaluec                 C   s$   t | |d}||kp|du o|duS )zA 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_   r`   stream_valuer   r   r   _is_compat_stream_attr   s   rb   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_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"   TextIOrc   r^   r   )	rd   r   r   re   rf   r	   r
   binary_readerpossible_binary_readerr   r   r   _force_correct_text_stream   s&   
	rj   text_readerc                 C      t | ||tt|dS )Nr	   )rj   rS   rZ   )rk   r   r   r	   r   r   r   _force_correct_text_reader     rn   text_writerc                 C   rl   )Nr
   )rj   rT   r\   )rp   r   r   r
   r   r   r   _force_correct_text_writer(  ro   rr   c                  C      t tj} | d u rtd| S )Nz6Was not able to determine binary stream for sys.stdin.)rZ   r   stdinRuntimeError)readerr   r   r   get_binary_stdin8     
rw   c                  C   rs   )Nz7Was not able to determine binary stream for sys.stdout.)r\   r   stdoutru   writerr   r   r   get_binary_stdout?  rx   r|   c                  C   rs   )Nz7Was not able to determine binary stream for sys.stderr.)r\   r   stderrru   rz   r   r   r   get_binary_stderrF  rx   r~   c                 C   ,   t tj| |}|d ur|S ttj| |ddS )NTrm   )_get_windows_console_streamr   rt   rn   r   r   r   r   r   r   get_text_stdinM     r   c                 C   r   NTrq   )r   r   ry   rr   r   r   r   r   get_text_stdoutV  r   r   c                 C   r   r   )r   r   r}   rr   r   r   r   r   get_text_stderr_  r   r   filezos.PathLike[str]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_openh  s   
r   rstrictfilenamezt.Union[str, os.PathLike[str]]atomicc              
      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 rdn|}W n3 ty } z'|j
|jkst jdkr|j
|jkrt j|jrt |jt jrW Y d }~q d }~ww |d urt |
| 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arE   Fr   Tr   zAppending 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.rE   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   rw   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!   IOr6   )r   r   r   r   r   binaryr   r   permflagstmp_filenamefderB   afr   r   r   open_streamu  sn   





r   c                   @   s   e Zd Zdej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ejeje  dejddfddZdefddZdS )r   rB   r   real_filenamer   Nc                 C   s   || _ || _|| _d| _d S NF)_f_tmp_filename_real_filenameclosed)r'   rB   r   r   r   r   r   r&     s   
z_AtomicFile.__init__c                 C   s   | j S r   )r   r,   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   r;   r   r   r   r<     r=   z_AtomicFile.__getattr__c                 C   s   | S r   r   r,   r   r   r   	__enter__  s   z_AtomicFile.__enter__exc_type_c                 G   s   | j |d ud d S )N)r   )r   )r'   r   r   r   r   r   __exit__  s   z_AtomicFile.__exit__c                 C   s
   t | jS r   )reprr   r,   r   r   r   __repr__  s   
z_AtomicFile.__repr__F)r   r   )r0   r1   r2   r    r   r6   r4   r&   propertyr   r5   r   r<   r   r3   TypeBaseExceptionr   r   r   r   r   r   r     s    "
$r   c                 C   s   t d| S )NrG   )_ansi_resub)r`   r   r   r   
strip_ansi  r=   r   c                 C   s0   t | ttfr| j} t | ttfs| jjdS )Nz
ipykernel.)rQ   r#   r   r$   r)   r1   
startswithr]   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   rt   r.   r   )r   r   r   r   r   should_strip_ansi  s
   r      )r   c                  C   s   dd l } |  S rP   )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   )r   	reset_all)s_writeansi_wrapperr   r   _safe_write  s   
z'auto_wrap_for_ansi.<locals>._safe_write)r   getr+   coloramar   AnsiToWin32r    r!   rg   r   rI   )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   rt   getfilesystemencodingr   r   r   r   r   .  s   rB   c                 C   s   d S r   r   )rB   r   r   r   r   r   r   1  s   r   rE   c                 C   s   t t| S r   )lenr   )rE   r   r   r   term_len7  r=   r   c                 C   s    z|   W S  ty   Y dS w r   )r.   r+   r]   r   r   r   r.   ;  s
   
r.   src_funcwrapper_funcc                    s(   t   dtjtj f fdd}|S )Nr   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   )r   r+   r   cacher   r   r   r   funcH  s$   
z&_make_cached_stream_func.<locals>.func)r   r    r3   rg   )r   r   r   r   r   r   _make_cached_stream_funcB  s   r   c                   C      t jS r   )r   rt   r   r   r   r   <lambda>^      r   c                   C   r   r   )r   ry   r   r   r   r   r   _  r   c                   C   r   r   )r   r}   r   r   r   r   r   `  r   )rt   ry   r}   binary_streamstext_streamsr/   r   )NN)r   Nr   Fr   )Fr   ior   rer   typingr    weakrefr   platformr   CYGWINWINr   r3   Callablerg   __annotations__compiler   r"   r4   r5   r   r   r   r6   r   TextIOWrapperr   r#   rS   rT   rZ   r\   r^   rb   rc   rj   rn   rr   rw   r|   r~   r   r   r   UnionrN   r   Tupler   r   r   r   r   _winconsoler   r   r   MutableMappingr   r.   r   _default_text_stdin_default_text_stdout_default_text_stderrr   Mappingr   r   r   r   r   <module>   s  
 "

 E 	"""		


2








	


Q
'


$	"