o 7]hM@s^ddlZddlmZmZmZmZddlmZddlm Z er$ddl m Z Gdddej Z dS) N)ListAnyIO TYPE_CHECKING) AnsiDecoder)Text)Consolec@sneZdZdZdddeeddfddZedeefd d Zd ede fd d Z dede fddZ dddZ dS) FileProxyzAWraps a file (e.g. sys.stdout) and redirects writes to a console.consoler filereturnNcCs||_||_g|_t|_dSN)_FileProxy__console_FileProxy__file_FileProxy__bufferr_FileProxy__ansi_decoder)selfr r r=/usr/lib/python3/dist-packages/pip/_vendor/rich/file_proxy.py__init__s zFileProxy.__init__cCs|jS)zGet proxied file.)rrrrrrich_proxied_fileszFileProxy.rich_proxied_filenamecCs t|j|Sr)getattrr)rrrrr __getattr__s zFileProxy.__getattr__textcst|tstdt|jj}g}|r8|d\}}}|r0|d|||dd=n||n|s|rej }|t dfdd|D}| |Wdt |S1s`wYt |S)Nz"write() argument must be str, not  c3s|] }j|VqdSr)r decode_line).0linerrr ,s  z"FileProxy.write..) isinstancestr TypeErrortype__name__r partitionappendjoinrrprintlen)rrbufferlinesr!new_liner outputrrrwrites.     zFileProxy.writecCs.|j}|r|jd||dd=dSdS)Nr)rrr+r*)rr-rrrflush2s zFileProxy.flush)r N)r' __module__ __qualname____doc__rr$rpropertyrrrintr1r2rrrrr sr )iotypingrrrransirrrr r TextIOBaser rrrrs