a czI @sfUddlZddlZddlZddlZddlZddlZddlmZej dZ ej do^dej vZ dejvozdejdd vZej doe oe ZdZejejejgejfed <ed Zed d dZdoejejeejeeeejdddZeedddZejedddZ Gdddej!Z"GdddZ#dpejeedddZ$dqejeedd d!Z%ejejejdd"d#Z&ejejejdd$d%Z'ejedd&d'Z(ejeejeed(d)d*Z)ejejeejeed+d,d-Z*drejejeejeejejegefejejgejejfeeejd.d/d0Z+dsejejeejeeejd1d2d3Z,dtejejeejeeejd4d5d6Z-ejd d7d8Z.ejd d9d:Z/ejd d;d<Z0duejeejeejd=d>d?Z1dvejeejeejd=d@dAZ2dwejeejeejd=dBdCZ3ej4eej5e6feejeejeejdDdEdFZ7dxeeejeejeeej8ejefdIdJdKZ9GdLdMdMZ:eedNdOdPZ;ejeddQdRZm?Z?ed dXdYZ@eZAejBejejfedZ<dzejejeejdSd[d Zn8ed d\dYZ@ejejeejeejejd]d^d_Z?ee6d`dadbZCejeddcddZDejgejfejgejfejgejfdedfdgZEeEdhdie1ZFeEdjdie2ZGeEdkdie3ZHe.e/e0dlZIejJeejgejffedm<e1e2e3dlZKejJeejejeejegejffedn<dS){N)WeakKeyDictionarycygwinwinZGCCAPPENGINE_RUNTIMEz Development/SERVER_SOFTWAREauto_wrap_for_ansiz\033\[[;?0-9]*[a-zA-Z]returncCstptSN)sysgetfilesystemencodinggetdefaultencodingrrZ/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/click/_compat.pyget_filesystem_encodingsrF)streamencodingerrorsforce_readableforce_writabler cCs0|durt|}|durd}t|||d||dS)NreplaceT)line_bufferingrr)get_best_encoding_NonClosingTextIOWrapper)rrrrrrrr_make_text_streamsr)rr cCs,zt|jdkWSty&YdS0dS)z$Checks if a given encoding is ascii.asciiFN)codecslookupname LookupError)rrrris_ascii_encoding-s r!)rr cCs$t|ddpt}t|r dS|S)z1Returns the default stream encoding if not found.rNzutf-8)getattrr rr!rrvrrrr5src s\eZdZd ejejeejeeeejddfdd Z ddddZ edd d Z Z S) rFN)rrrrrextrar c s8ttjt||||_}tj|||fi|dSr )tcastBinaryIO _FixupStream_streamsuper__init__)selfrrrrrr% __class__rrr,>s  z!_NonClosingTextIOWrapper.__init__r cCs$z |WntyYn0dSr )detach Exceptionr-rrr__del__Ls  z _NonClosingTextIOWrapper.__del__cCs |jSr )r*isattyr2rrrr4Rsz_NonClosingTextIOWrapper.isatty)FF) __name__ __module__ __qualname__r&r(OptionalstrboolAnyr,r3r4 __classcell__rrr.rr=src@sreZdZdZdejeedddZeej dddZ e e d d d Z ed d dZed ddZed ddZdS)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). F)rrrcCs||_||_||_dSr )r*_force_readable_force_writable)r-rrrrrrr,asz_FixupStream.__init__rr cCs t|j|Sr )r"r*r-rrrr __getattr__ksz_FixupStream.__getattr__)sizer cCs2t|jdd}|dur&tt||S|j|S)Nread1)r"r*r&r'bytesread)r-rBfrrrrCnsz_FixupStream.read1r cCsX|jr dSt|jdd}|dur.tt|Sz|jdWntyRYdS0dS)NTreadablerF)r=r"r*r&r'r:rEr1r-xrrrrGvs z_FixupStream.readablec Cs~|jr dSt|jdd}|dur.tt|Sz|jdWn:tyxz|jdWntyrYYdS0Yn0dS)NTwritablerF)r>r"r*r&r'r:writer1rHrrrrJs  z_FixupStream.writablecCsTt|jdd}|dur$tt|Sz|j|jWntyNYdS0dS)NseekableFT)r"r*r&r'r:seektellr1rHrrrrMs z_FixupStream.seekableN)FF)r5r6r7__doc__r&r(r:r,r9r;rAintrDrCrGrJrMrrrrr)Ws   r))rdefaultr cCs.zt|dtWSty(|YS0dSNr) isinstancerErDr1rrRrrr_is_binary_readers rVc CsPz|dWn<tyJz|dWYdSty@Yn0|YS0dS)NrKrFT)rLr1rUrrr_is_binary_writers    rWcCsHt|drttj|St|dd}|durDt|drDttj|SdSNFbufferT)rVr&r'r(r"rbufrrr_find_binary_readers   r\cCsHt|drttj|St|dd}|durDt|drDttj|SdSrX)rWr&r'r(r"rZrrr_find_binary_writers   r]cCstt|ddpdS)z3A stream is misconfigured if its encoding is ASCII.rNr)r!r"rrrr_stream_is_misconfiguredsr_)rattrvaluer cCs$t||d}||kp"|duo"|duS)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")rr`raZ stream_valuerrr_is_compat_stream_attrs rb)rrrr cCst|d|ot|d|S)zcCheck if a stream's encoding and errors attributes are compatible with the desired values. rr)rb)rrrrrr_is_compatible_text_streams  rc) text_streamrr is_binary find_binaryrrr c Cs~||drttj|}nFttj|}t|||rH|durDt|sH|S||}|dur\|S|}|durld}t|||||dS)NFr)rr)r&r'r(TextIOrcr_r) rdrrrerfrrZ binary_readerZpossible_binary_readerrrr_force_correct_text_streams,  rh) text_readerrrrr cCst|||tt|dS)Nr)rhrVr\)rirrrrrr_force_correct_text_reader!srk) text_writerrrrr cCst|||tt|dS)Nr)rhrWr])rlrrrrrr_force_correct_text_writer1srncCsttj}|durtd|S)Nz6Was not able to determine binary stream for sys.stdin.)r\r stdin RuntimeError)readerrrrget_binary_stdinAs rrcCsttj}|durtd|S)Nz7Was not able to determine binary stream for sys.stdout.)r]r stdoutrpwriterrrrget_binary_stdoutHs rvcCsttj}|durtd|S)Nz7Was not able to determine binary stream for sys.stderr.)r]r stderrrprtrrrget_binary_stderrOs rx)rrr cCs,ttj||}|dur|Sttj||ddS)NTrj)_get_windows_console_streamr rorkrrr$rrrget_text_stdinVsr{cCs,ttj||}|dur|Sttj||ddSNTrm)ryr rsrnrzrrrget_text_stdout_sr}cCs,ttj||}|dur|Sttj||ddSr|)ryr rwrnrzrrrget_text_stderrhsr~)filemoderrr cCs"d|vrt||St||||dS)z?Handles not passing ``encoding`` and ``errors`` in binary mode.brr)open)rrrrrrr _wrap_io_openqs rrstrict)filenamerrratomicr c s(dv}t|dkrhtfdddDrJ|r:tdfSt||ddfS|rXtdfSt||ddfS|s~t|||dfSd vrtd d vrtd d vrtdddl }ddl }zt |j }Wnt yd}Yn0tjtjBtjB} |r| ttddO} tjtj|d|dd} z&t| | |durJdn|} WqWnt y} zf| j |jkstjdkr| j |jkrtj| jrt| jtjrWYd} ~ qWYd} ~ n d} ~ 00q|durt| |t| ||} t| | tj |}t!"t!j#|dfS)Nr-c3s|]}|vVqdSr r).0mrrr rKzopen_stream..)warIFrTrzAppending 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.rIz&Use the `overwrite`-parameter instead.rz,Atomic writes only make sense with `w`-mode.rO_BINARYz.__atomic-writelZ08xint)$osfsdecodeanyrvr}rrr{r ValueErrorerrnorandomstatst_modeOSErrorO_RDWRO_CREATO_EXCLr"pathjoindirname randrangerEEXISTrEACCESisdirraccessW_OKchmod _AtomicFilerealpathr&r'IO)rrrrrbinaryrrpermflags tmp_filenamefderFafrrr open_stream~sh          rc@s|eZdZejeeddddZeedddZde dd d d Z eej d d dZ ddddZ ddZedddZdS)rN)rFr real_filenamer cCs||_||_||_d|_dSNF)_f _tmp_filename_real_filenameclosed)r-rFrrrrrr,sz_AtomicFile.__init__r cCs|jSr )rr2rrrrsz_AtomicFile.nameF)deleter cCs.|jr dS|jt|j|jd|_dS)NT)rrcloserrrr)r-rrrrrs  z_AtomicFile.closer?cCs t|j|Sr )r"rr@rrrrAsz_AtomicFile.__getattr__cCs|Sr rr2rrr __enter__sz_AtomicFile.__enter__cCs|j|duddS)N)r)r)r-exc_type exc_valuetbrrr__exit__sz_AtomicFile.__exit__cCs t|jSr )reprrr2rrr__repr__sz_AtomicFile.__repr__)F)r5r6r7r&rr9r,propertyrr:rr;rArrrrrrrrsr)rar cCs td|S)Nr)_ansi_resub)rarrr strip_ansisrcCs$t|ttfr|j}q|jjdS)Nz ipykernel.)rTr)rr*r/r6 startswithr^rrr_is_jupyter_kernel_outputsr)rcolorr cCs0|dur*|durtj}t| o(t| S| Sr )r ror4r)rrrrrshould_strip_ansis r)rycCsddl}|SrS)localegetpreferredencoding)rrrr_get_argv_encodingsr_ansi_stream_wrapperscszt|}Wnty$d}Yn0|dur2|Sddl}t||}|j||dttjj }|j fdd}||_ z |t|<WntyYn0|S)zbSupport ANSI color and style codes on Windows by wrapping a stream with colorama. Nr)stripcs,z |WSty&Yn0dSr ) BaseException reset_all)s_writeZ ansi_wrapperrr _safe_write$s   z'auto_wrap_for_ansi.._safe_write) rgetr1coloramar AnsiToWin32r&r'rgrrL)rrcachedrrr$rrrrrs$     cCsttjddptS)Nr)r"r rorrrrrr6s)rFrrr cCsdSr r)rFrrrrrry9sry)rIr cCs tt|Sr )lenr)rIrrrterm_len?srcCs$z |WStyYdS0dSr)r4r1r^rrrr4Cs  r4)src_func wrapper_funcr cs"ttjdfdd }|S)Nr csb}z|}Wnty*d}Yn0|dur8|S}z ||<Wnty\Yn0|Sr )rr1r#cacherrrrfuncOs    z&_make_cached_stream_func..func)rr&rg)rrrrrr_make_cached_stream_funcJsrcCstjSr )r rorrrrarKrcCstjSr )r rsrrrrrbrKcCstjSr )r rwrrrrrcrK)rorsrwbinary_streams text_streams)FF)F)F)FF)F)F)NN)NN)NN)rNrF)NN)N)Lriorrer typingr&weakrefrplatformrZCYGWINversionZMSYS2environrZ APP_ENGINEZWINrr8Callablerg__annotations__compilerr9rr(r:rr!rr TextIOWrapperrr)rVrWr\r]r_rbrcrhrkrnrrrvrxr{r}r~UnionPathLikerQrTuplerrrrrZ _winconsoleryrrMutableMappingrr4rZ_default_text_stdinZ_default_text_stdoutZ_default_text_stderrrMappingrrrrrs   "  E      2       P   '  $ "