o �J�hI�@s�UddlmZddlZddlmZddlZddlZddlZddl Z ddl Z ddl m Z ddlmZe j�d�Ze j�d�ZdZded<e�d �Z d�d�dd�Zd�dd�Zd�dd�ZGdd�dej�ZGdd �d �Zd�d�d"d#�Zd�d�d$d%�Zd�d'd(�Z d�d)d*�Z!d�d+d,�Z"d�d/d0�Z#d�d1d2�Z$ d�d�d8d9�Z% d�d�d;d<�Z& d�d�d>d?�Z'd�d@dA�Z(d�dBdC�Z)d�dDdE�Z*d�d�dFdG�Z+d�d�dHdI�Z,d�d�dJdK�Z-d�dOdP�Z. Q  R d�d�dWdX�Z/GdYdZ�dZ�Z0d�d[d\�Z1d�d]d^�Z2 d�d�dbdc�Z3e j�d��re�rdddel4m5Z5d�dfdg�Z6e�Z7dhedi<d�d�djd�Zn d�dkdg�Z6d�dndo�Z5d�drds�Z8d�dtdu�Z9d�dzd{�Z:e:d|d}�e+�Z;e:d~d}�e,�Z<e:dd}�e-�Z=e(e)e*d��Z>d�ed�<e+e,e-d��Z?d�ed�<dS)��)� annotationsN)� TracebackType��WeakKeyDictionary�cygwin�winz't.Callable[[t.TextIO], t.TextIO] | None�auto_wrap_for_ansiz\033\[[;?0-9]*[a-zA-Z]F�stream� t.BinaryIO�encoding� str | None�errors�force_readable�bool�force_writable�return�t.TextIOcCs0|durt|�}|durd}t|||d||d�S)N�replaceT)�line_bufferingrr)�get_best_encoding�_NonClosingTextIOWrapper)r r r rr�r�KC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\click\_compat.py�_make_text_streams�r�strcCs(z t�|�jdkWStyYdSw)z$Checks if a given encoding is ascii.�asciiF)�codecs�lookup�name� LookupError)r rrr�is_ascii_encoding(s  �r � t.IO[t.Any]cCs$t|dd�p t��}t|�rdS|S)z1Returns the default stream encoding if not found.r Nzutf-8)�getattr�sys�getdefaultencodingr �r �rvrrrr0srcs8eZdZ  dd�fdd� Zddd�Zddd�Z�ZS)rFr r r r r rrr�extra�t.Anyr�Nonec s8t�tjt|||��|_}t�j|||fi|��dS�N)�t�cast�BinaryIO� _FixupStream�_stream�super�__init__)�selfr r r rrr'�� __class__rrr19s  �z!_NonClosingTextIOWrapper.__init__cCs$z|��WdStyYdSwr*)�detach� Exception�r2rrr�__del__Gs  �z _NonClosingTextIOWrapper.__del__cCs |j��Sr*)r/�isattyr7rrrr9Ms z_NonClosingTextIOWrapper.isatty�FF)r r r r r r rrrrr'r(rr))rr)�rr)�__name__� __module__� __qualname__r1r8r9� __classcell__rrr3rr8s � rc@sReZdZdZ  dddd �Zddd�Zddd�Zd dd�Zd dd�Zd dd�Z dS)!r.aQThe 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 rrrcCs||_||_||_dSr*)r/�_force_readable�_force_writable)r2r rrrrrr1\s z_FixupStream.__init__rrrr(cC� t|j|�Sr*)r"r/�r2rrrr� __getattr__f� z_FixupStream.__getattr__�size�int�bytescCs2t|jdd�}|durt�t||��S|j�|�S)N�read1)r"r/r+r,rH�read)r2rF�frrrrIis z_FixupStream.read1cCsV|jrdSt|jdd�}|durt�t|��Sz |j�d�WdSty*YdSw)NT�readablerF)r@r"r/r+r,rrJr6�r2�xrrrrLqs ��z_FixupStream.readablec Cs||jrdSt|jdd�}|durt�t|��Sz |j�d�WdSty=z |j�d�WYdSty<YYdSww)NT�writable�F)rAr"r/r+r,r�writer6rMrrrrO}s  � ���z_FixupStream.writablecCsRt|jdd�}|durt�t|��Sz |j�|j���WdSty(YdSw)N�seekableFT)r"r/r+r,r�seek�tellr6rMrrrrR�s ��z_FixupStream.seekableNr:)r r rrrr�rrrr()rFrGrrHr;) r<r=r>�__doc__r1rDrIrLrOrRrrrrr.Rs  �   r.�defaultcCs*z t|�d�t�WSty|YSw�Nr)� isinstancerJrHr6�r rWrrr�_is_binary_reader�s  �r[c CsLz|�d�WdSty%z |�d�WYdSty$Y|YSww)NrP�FT)rQr6rZrrr�_is_binary_writer�s  �  ��r]�t.BinaryIO | NonecC�Ht|d�r t�tj|�St|dd�}|dur"t|d�r"t�tj|�SdS�NF�bufferT)r[r+r,r-r"�r �bufrrr�_find_binary_reader��  rdcCr_r`)r]r+r,r-r"rbrrr�_find_binary_writer�rerfcCstt|dd�pd�S)z3A stream is misconfigured if its encoding is ASCII.r Nr)r r"�r rrr�_stream_is_misconfigured��rh�attr�valuecCs$t||d�}||kp|duo|duS)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 rjrkZ stream_valuerrr�_is_compat_stream_attr�s rlcCst|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 rrr�_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 Cs~||d�r t�tj|�}n#t�tj|�}t|||�r$|dur"t|�s$|S||�}|dur.|S|}|dur6d}t|||||d�S)NFr)rr)r+r,r-�TextIOrmrhr) rnr r rorqrrZ binary_readerZpossible_binary_readerrrr�_force_correct_text_stream�s&  �rt� text_readercC�t|||tt|d�S)N�r)rtr[rd)rur r rrrr�_force_correct_text_reader��rx� text_writercCrv)N�r)rtr]rf)rzr r rrrr�_force_correct_text_writer,ryr|cC�ttj�}|dur td��|S)Nz6Was not able to determine binary stream for sys.stdin.)rdr#�stdin� RuntimeError)�readerrrr�get_binary_stdin<� r�cCr})Nz7Was not able to determine binary stream for sys.stdout.)rfr#�stdoutr��writerrrr�get_binary_stdoutCr�r�cCr})Nz7Was not able to determine binary stream for sys.stderr.)rfr#�stderrrr�rrr�get_binary_stderrJr�r�cC�,ttj||�}|dur |Sttj||dd�S)NTrw)�_get_windows_console_streamr#r~rx�r r r&rrr�get_text_stdinQ�r�cCr��NTr{)r�r#r�r|r�rrr�get_text_stdoutXr�r�cCr�r�)r�r#r�r|r�rrr�get_text_stderr_r�r��file�str | os.PathLike[str] | int�modecCs"d|vr t||�St||||d�S)z?Handles not passing ``encoding`` and ``errors`` in binary mode.�b�r r )�open)r�r�r r rrr� _wrap_io_openfs r��r�strict�filename�str | os.PathLike[str]�atomic�tuple[t.IO[t.Any], bool]c sd�v}t�|�}t�|�dkr9t�fdd�dD��r*|r"t�dfSt||d�dfS|r1t�dfSt||d�dfS|sDt|�||�dfSd �vrLt d ��d �vrTt d ��d �vr\t d��ddl }ddl }zt� |�j }Wn tywd}YnwtjtjBtjB} |r�| ttdd�O} tj�tj�|�d|�d�d���} zt�| | |dur�dn|�} Wn3ty�} z'| j |jks�tjdkr�| j |jkr�tj�| j�r�t�| jtj�r�WYd} ~ q��d} ~ ww|dur�t�| |�t| �||�} t | | tj�!|��}t"�#t"j$t"j%|�dfS)Nr��-c3s�|]}|�vVqdSr*r)�.0�m�r�rr� <genexpr>�s�zopen_stream.<locals>.<genexpr>)�w�arNFr�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.rNz&Use the `overwrite`-parameter instead.r�z,Atomic writes only make sense with `w`-mode.r�O_BINARYz.__atomic-writelZ08xi��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��EEXISTrZEACCES�isdirr��access�W_OK�chmod� _AtomicFile�realpathr+r,�IO�Any)r�r�r r r��binaryr�r��perm�flags� tmp_filename�fd�erK�afrr�r� open_streamssn   � � �    �� �� r�c@sXeZdZd"dd �Zed#d d ��Zd$d%dd�Zd&dd�Zd'dd�Zd(dd�Z d#dd �Z d!S))r�rKr!r�r� real_filenamerr)cCs||_||_||_d|_dS�NF)�_f� _tmp_filename�_real_filename�closed)r2rKr�r�rrrr1�s z_AtomicFile.__init__cCs|jSr*)r�r7rrrr�sz_AtomicFile.nameF�deletercCs.|jrdS|j��t�|j|j�d|_dS)NT)r�r��closer�rr�r�)r2r�rrrr��s   z_AtomicFile.closerr(cCrBr*)r"r�rCrrrrD�rEz_AtomicFile.__getattr__cCs|Sr*rr7rrr� __enter__�sz_AtomicFile.__enter__�exc_type�type[BaseException] | None� exc_value�BaseException | None�tb�TracebackType | NonecCs|j|dud�dS)N)r�)r�)r2r�r�r�rrr�__exit__�riz_AtomicFile.__exit__cCs t|j�Sr*)�reprr�r7rrr�__repr__�s z_AtomicFile.__repr__N)rKr!r�rr�rrr)�rr�F)r�rrr)rU)rr�)r�r�r�r�r�r�rr)) r<r=r>r1�propertyrr�rDr�r�r�rrrrr��s      r�cCs t�d|�S)Nr\)�_ansi_re�sub)rkrrr� strip_ansi�rEr�cCs0t|ttf�r|j}t|ttf�s|jj�d�S)Nz ipykernel.)rYr.rr/r4r=� startswithrgrrr�_is_jupyter_kernel_output�s�r��t.IO[t.Any] | None�color� bool | NonecCs0|dur|dur tj}t|� ot|� S| Sr*)r#r~r9r�)r r�rrr�should_strip_ansi�s r��)r�cCsddl}|��SrX)�locale�getpreferredencoding)r�rrr�_get_argv_encodingsr�z'cabc.MutableMapping[t.TextIO, t.TextIO]�_ansi_stream_wrapperscs�zt�|�}Wn tyd}Ynw|dur|Sddl}t||�}|j||d��t�tj�j �}|j �d ��fdd � }||_ z|t|<W|StyPY|Sw) zbSupport ANSI color and style codes on Windows by wrapping a stream with colorama. Nr)�strip�srrrGcs$z�|�WSty����wr*)� BaseExceptionZ reset_all)r��Z_writeZ ansi_wrapperrr� _safe_writes   �z'auto_wrap_for_ansi.<locals>._safe_write)r�rrrG) r��getr6�coloramar�Z AnsiToWin32r+r,rsr rQ)r r��cachedr�r�r&r�rr�rr s* �   ��cCsttjdd�p t��S)Nr )r"r#r~�getfilesystemencodingrrrrr�/srK�t.TextIO | NonecCsdSr*r)rKr r rrrr�2sr�rNrGcCs tt|��Sr*)�lenr�)rNrrr�term_len8rEr�cCs z|��WStyYdSwr�)r9r6rgrrrr9<s   �r9�src_func�t.Callable[[], t.TextIO | None]� wrapper_func�t.Callable[[], t.TextIO]cst��d���fdd� }|S)Nrr�csn��}|dur dSz��|�}Wn tyd}Ynw|dur"|S��}z|�|<W|Sty6Y|Swr*)r�r6r%��cacher�r�rr�funcIs$ �  ��z&_make_cached_stream_func.<locals>.func)rr�r)r�r�r�rr�r�_make_cached_stream_funcCsr�cC�tjSr*)r#r~rrrr�<lambda>_�rcCrr*)r#r�rrrrr`rcCrr*)r#r�rrrrrar)r~r�r�z-cabc.Mapping[str, t.Callable[[], t.BinaryIO]]�binary_streamszAcabc.Mapping[str, t.Callable[[str | None, str | None], t.TextIO]]� text_streamsr:) r r r r r r rrrrrr)r rrr)r r!rrr�)r r!rWrrr)r r!rr^)r rrr)r rrjrrkr rr)r rr r r r rr)rnr!r r r r rorprqrrrrrrrr) rur!r r r r rrrr) rzr!r r r r rrrr)rr )NN)r r r r rr) r�r�r�rr r r r rr!)r�Nr�F) r�r�r�rr r r r r�rrr�)rkrrr)r r!rr)r r�r�r�rrr�r*)r rr�r�rr)rKrr r r r rr�)rNrrrG)r�r�r�r�rr�)@� __future__rr�collections.abc�abc�cabc�ior��rer#�typingr+�typesr�weakrefr�platformr�ZCYGWINZWINr�__annotations__�compiler�rr r� TextIOWrapperrr.r[r]rdrfrhrlrmrtrxr|r�r�r�r�r�r�r�r�r�r�r�r�Z _winconsoler�r�r�r�r9r�Z_default_text_stdinZ_default_text_stdoutZ_default_text_stderrrrrrrr�<module>s�        �   E    �2 � �        �Q $  �   %    ��
Memory