a c@sUddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZejdksJddlZddlmZddlmZe e ZejZejZejZejZej Z ej!Z!eedejfZ"ee eee e dej#fZ$ee e dejfZ%edZ&edZ'edZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2zdd lm3Z3Wne4ydZ5Yn(0Gd!d"d"eZ6e3j7Z7e3j8Z8d=d$d%Z5Gd&d'd'ej9Z:Gd(d)d)e:Z;Gd*d+d+e:Zej?d.d/d0Z@ej>ej?d.d1d2ZAej>ej?d.d3d4ZBe@eAeBd5ZCejDeEejFej>gej?ffeGd6<ej?eHd7d8d9ZIej?ejJeKejJeKejJej?d:d;d<ZLdS)>N)byref)c_char)c_char_p)c_int) c_ssize_t)c_ulong)c_void_p)POINTER) py_object) Structure)DWORD)HANDLE)LPCWSTR)LPWSTR)_NonClosingTextIOWrapperwin32)windll) WINFUNCTYPEGetCommandLineWCommandLineToArgvW LocalFreeiiiii) pythonapic @sReZdZdefdefdefdefdefdefdefdefd efd efd efg Z d S) Py_bufferbufobjlenitemsizereadonlyndimformatshapestrides suboffsetsZinternalN) __name__ __module__ __qualname__rr rrr c_ssize_p_fields_r,r,^/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/click/_winconsole.pyrKsrFc Cs^t}|rtnt}tt|t||z$t|j}||j Wt t|St t|0dSN) rPyBUF_WRITABLE PyBUF_SIMPLEPyObject_GetBufferr rrr from_addressrPyBuffer_Release)rwritablerflagsZ buffer_typer,r,r- get_buffer]s    r6cs$eZdZddZfddZZS)_WindowsConsoleRawIOBasecCs ||_dSr.)handle)selfr8r,r,r-__init__jsz!_WindowsConsoleRawIOBase.__init__cstdSNT)superisattyr9 __class__r,r-r=ms z_WindowsConsoleRawIOBase.isatty)r'r(r)r:r= __classcell__r,r,r?r-r7isr7c@seZdZddZddZdS)_WindowsConsoleReadercCsdSr;r,r>r,r,r-readablessz_WindowsConsoleReader.readablecCst|}|sdS|dr tdt|dd}|d}t}tt|j||t|d}tt krht d|s|t dt|dt krdSd|jS)Nrrz>cannot read odd number of bytes from UTF-16-LE encoded consoleT)r4g?zWindows error: )r ValueErrorr6r ReadConsoleWr r8r GetLastErrorERROR_OPERATION_ABORTEDtimesleepOSErrorEOFvalue)r9bZbytes_to_be_readbufferZcode_units_to_be_readZcode_units_readrvr,r,r-readintovs0    z_WindowsConsoleReader.readintoN)r'r(r)rCrPr,r,r,r-rBrsrBc@s(eZdZddZeddZddZdS)_WindowsConsoleWritercCsdSr;r,r>r,r,r-r4sz_WindowsConsoleWriter.writablecCs"|tkr dS|tkrdSd|S)N ERROR_SUCCESSERROR_NOT_ENOUGH_MEMORYzWindows error )rRrS)errnor,r,r-_get_error_messages z(_WindowsConsoleWriter._get_error_messagecCslt|}t|}t|td}t}tt|j||t|dd|j }|dkrh|dkrht | t |S)Nrr) rr6minMAX_BYTES_WRITTENr WriteConsoleWr r8rrLrJrUrF)r9rMZbytes_to_be_writtenrZcode_units_to_be_writtenZcode_units_writtenZ bytes_writtenr,r,r-writes z_WindowsConsoleWriter.writeN)r'r(r)r4 staticmethodrUrYr,r,r,r-rQs rQc@seZdZejejddddZeedddZ ej e dd d Z ej ej dd d d ZeejdddZedddZddZdS) ConsoleStreamN) text_stream byte_streamreturncCs||_||_dSr.) _text_streamrN)r9r\r]r,r,r-r:szConsoleStream.__init__)r^cCs|jjSr.)rNnamer>r,r,r-r`szConsoleStream.name)xr^cCsBt|tr|j|Sz |Wnty4Yn0|j|Sr.) isinstancestrr_rYflush ExceptionrN)r9rar,r,r-rYs    zConsoleStream.write)linesr^cCs|D]}||qdSr.)rY)r9rfliner,r,r- writelinesszConsoleStream.writelines)r`r^cCs t|j|Sr.)getattrr_)r9r`r,r,r- __getattr__szConsoleStream.__getattr__cCs |jSr.)rNr=r>r,r,r-r=szConsoleStream.isattycCsd|jd|jdS)Nz)r`encodingr>r,r,r-__repr__szConsoleStream.__repr__)r'r(r)tTextIOBinaryIOr:propertyrcr`AnyStrintrYIterablerhAnyrjboolr=rmr,r,r,r-r[s r[) buffer_streamr^cCs.ttttdddd}ttjt||SN utf-16-lestrictT)line_buffering) rioBufferedReaderrB STDIN_HANDLErncastror[rwr\r,r,r-_get_text_stdins rcCs.ttttdddd}ttjt||Srx) rr|BufferedWriterrQ STDOUT_HANDLErnrror[rr,r,r-_get_text_stdouts rcCs.ttttdddd}ttjt||Srx) rr|rrQ STDERR_HANDLErnrror[rr,r,r-_get_text_stderrs r)rrr_stream_factories)fr^c CsTt|dsdSz |}Wnttjfy4YdS0t|}tt|t t S)NfilenoF) hasattrrrJr|UnsupportedOperationmsvcrtZ get_osfhandlervGetConsoleModerr )rrr8r,r,r- _is_consoles   r)rrlerrorsr^cCsZtdurV|dvrV|dvrVt|rVt|}|durVt|dd}|durNdS||SdS)N>Nry>rzNrN)r6rrgetrri)rrlrfuncrMr,r,r-_get_windows_console_streams r)F)Mr|sysrHtypingrnctypesrrrrrrrr r r Zctypes.wintypesr r rr_compatrplatformrrrr*kernel32Z GetStdHandlerErXrrFrshell32rrr~rrr0r/rRrSrGZ STDIN_FILENOZ STDOUT_FILENOZ STDERR_FILENOrKrWr ImportErrorr6rr1r3 RawIOBaser7rBrQr[rprorrrrMappingrsCallable__annotations__rvrOptionalrcrr,r,r,r- s                     #     (