U e5dS@sddlZddlZddlZddlmZejZddddddd d d d d ddddddddgZddZ ddZ dekrdZ dZ ddl Tzddl mZedWnek rYnXddlZzddl mZWnek rYnXddl Z ee e [ nd ekrd Z d!Z ddlTzddlmZedWnek r>YnXddlZddlZee e[zddlmZWnek rYnXned"eejd#<dd$lmZmZmZmZmZmZmZm Z [e d%re!Z"d&d'Z#e$Z%e#d(d)e#d*d+e#d,d-e#d.d/e#d0d1e#d2d3e#d4d5e#d6d7e#d8d9e#d:d;e#dd?e#d@dAe#dBdCe#dBdDe#dEd1e%Z&e$Z%e#d(d)e%Z'e$Z%e#dFdGe#dHd+e#dId-e#dJdKe#dJdLe#dMdNe%(ee#dOdPe#dQd1e#dRd1e#dSdTe dUr.e dVr.e#dWdUe%Z)e$Z%e#d(d)e#d,d-e#d.d/e#dXdYe#dZd+e d[r~e#d\d-e#d2d3e#d]d1e#d^d/e#d.d/e#dEd1e#d_d/e%Z*[%[["[#dZ+d`Z,daZ-ddddeZ.dfdgZ/dhdiZ0ededgdigddkdlZ1edle2ehe&krPe3ehe)krPddcddndodpZ4dqdrZ5edpdsdtZ6dudvZ7dwdxZ8dydzZ9d{d|Z:d}d~Z;edtdvdxdzd|d~gdddZZ>Gddde>Z?ze@ZAWneBk rddZAYnXdekredzeCZDWneBk r(ddZDYnXdekr>edddZEeEZF[EdddZGe d kZHedeHrddZIe?eFjJeIeKeIeKeAeDZL[IdddZMedddZNeN\ZOZP[Ne dr,e ds,e dr,dZQd`ZRZSedddgddZTddZUddZVddZWddZXeddddge drTddZYddZZeddge dr|ddZ[ddZ\eddgdddZ]GdddZ^ddZ_ddZ`e dse`Zadea_bGdddejcZde d krGdddZeddZfdS)N)_check_methodsaltsepcurdirpardirseppathseplinesepdefpathnamepathdevnullSEEK_SETSEEK_CURSEEK_ENDfsencodefsdecode get_exec_pathfdopenpopenextsepcCs |tkSN)globals)r r/usr/lib64/python3.8/os.py_exists'srcCs8z t|jWStk r2ddt|DYSXdS)NcSsg|]}|ddkr|qS)r_r).0nrrr .s z%_get_exports_list..)list__all__AttributeErrordir)modulerrr_get_exports_list*s r$posix )*)_exitr()_have_functionsntz zno os specific module foundzos.path)rrrrr rrr r)cCs"|tkr|tkrtt|dSr)_globalsr)_setadd)strfnrrr_addfsr0ZHAVE_FACCESSATaccessZ HAVE_FCHMODATchmodZ HAVE_FCHOWNATchownZ HAVE_FSTATATstatZHAVE_FUTIMESATutimeZ HAVE_LINKATlinkZ HAVE_MKDIRATmkdirZ HAVE_MKFIFOATmkfifoZ HAVE_MKNODATmknodZ HAVE_OPENATopenZHAVE_READLINKATreadlinkZ HAVE_RENAMEATrenameZHAVE_SYMLINKATsymlinkZ HAVE_UNLINKATunlinkrmdirZHAVE_UTIMENSATZ HAVE_FCHDIRchdirZ HAVE_FCHMODZ HAVE_FCHOWNZHAVE_FDOPENDIRlistdirscandirZ HAVE_FEXECVEexecveZHAVE_FTRUNCATEtruncateZ HAVE_FUTIMENSZ HAVE_FUTIMESZHAVE_FPATHCONFpathconfstatvfsfstatvfsZ HAVE_FSTATVFSZ HAVE_LCHFLAGSZchflagsZ HAVE_LCHMODlchownZ HAVE_LCHOWNZ HAVE_LUTIMESZ HAVE_LSTATZ MS_WINDOWSFcCst|\}}|s t|\}}|r||r|t|s|zt||dWntk rVYnXt}t|trpttd}||kr|dSzt||Wn$t k r|rt |sYnXdS)N)exist_okASCII) r splitexistsmakedirsFileExistsErrorr isinstancebytesr7OSErrorisdir)r moderLheadtailcdirrrrrPs$   rPcCsjt|t|\}}|s(t|\}}|rf|rfz t|Wntk rTYqfYnXt|\}}q(dSr)r?r rNrT)r rWrXrrr removedirss   rZcCsnt|\}}|r(|r(t|s(t|t||t|\}}|rj|rjz t|Wntk rhYnXdSr)r rNrOrPr<rZrT)oldnewrWrXrrrrenamess  r]Tc cst|}g}g}g}z t|}Wn8tk rX}z|dk rB||WYdSd}~XYnX|z.z t|} Wntk rYWqpYnXWnBtk r}z$|dk r||WYW5QRdSd}~XYnXz | } Wntk rd} YnX| r|| jn || j|sb| rb|r0d} n.z | } Wntk rVd} YnX| } | rb|| j qbW5QRX|r|||fVt j t j } }|D]4}|||}|s| |st ||||EdHqn,|D]}t ||||EdHq|||fVdS)NFT) fspathrBrTnext StopIterationis_dirappendr is_symlinkr islinkjoinwalk)toptopdownonerror followlinksdirsnondirs walk_dirs scandir_iterrorentryra walk_intorcrdredirnamenew_pathrrrrfs^;  "       rf.follow_symlinksdir_fdccst|trt|dst|}|s.t|d|d}t|t|d}zB|s^t |j r|t |t|r|t ||t|t|||EdHW5t|XdS)N __index__Frurw)rRinthasattrr^r4r:O_RDONLYclosestS_ISDIRst_moder samestat_fwalkrS)rgrhrirvrworig_sttopfdrrrfwalks!rc cst|}g}g}|s|rdng} |D]} | j} |r:t| } z4| rb|| | dk rl| | n || Wq$tk rz| r|| Wntk rYnXYq$Xq$|r||||fV| dkr|nt|| D]} z@|s|rt| |dd} n| \} } | jdd} t | t |d} Wn>tk r\}z|dk rD||WYqW5d}~XYnXz@|sxt | t| rt || }t| |||||EdHW5t | Xq|s||||fVdS)NF)rwrv)rvry)rBr rrarbrTrczipr4r:r|r}r rrer)rtoppathisbytesrhrirvrnrkrlentriesrpr rdirfderrdirpathrrrrsZ      rcGst||dSr)execvfileargsrrrexeclsrcGs |d}t||dd|dSN)rCrrenvrrrexeclesrcGst||dSr)execvprrrrexeclp"srcGs |d}t||dd|dSr)execvperrrrexeclpe)srcCst||dSr_execvperrrrr2srcCst|||dSrrrrrrr:src Cs|dk rt}||f}nt}|f}t}t|r@||f|dSd}t|}tdkrft|}tt|}|D]~}t ||}z||f|Wqjt t fk r} z| } W5d} ~ XYqjt k r} z| } |dkr| }W5d} ~ XYqjXqj|dk r|| dS)Nr*) rCrenvironr rrrr rmapreFileNotFoundErrorNotADirectoryErrorrT) rrr exec_funcargrest saved_exc path_listr"fullnameelast_excrrrrEs6    rc Csddl}|dkrt}||dtz|d}Wntk rPd}YnXtrz |d}Wnttfk rzYnX|dk rt d|}|dk rt |t rt |}W5QRX|dkrt }|tS)NrignorePATHsPATHz*env cannot contain 'PATH' and b'PATH' keys)warningsrcatch_warnings simplefilter BytesWarningget TypeErrorsupports_bytes_environKeyError ValueErrorrRrSrr rNr)rrr path_listbrrrres0     )MutableMappingc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_EnvironcCs.||_||_||_||_||_||_||_dSr) encodekey decodekey encodevalue decodevalueputenvunsetenv_data)selfdatarrrrrrrrr__init__sz_Environ.__init__cCs>z|j||}Wntk r2t|dYnX||Sr)rrrrrkeyvaluerrr __getitem__s z_Environ.__getitem__cCs.||}||}|||||j|<dSr)rrrrrrrr __setitem__s   z_Environ.__setitem__cCsD||}||z |j|=Wntk r>t|dYnXdSr)rrrr)rr encodedkeyrrr __delitem__s    z_Environ.__delitem__ccs$t|j}|D]}||VqdSr)rrr)rkeysrrrr__iter__s z_Environ.__iter__cCs t|jSr)lenrrrrr__len__sz_Environ.__len__cs$ddfddjDS)Nzenviron({{{}}})z, c3s*|]"\}}d||VqdS)z {!r}: {!r}N)formatrr)rrrrrr sz$_Environ.__repr__..)rreritemsrrrr__repr__s  z_Environ.__repr__cCst|Sr)dictrrrrcopysz _Environ.copycCs||kr|||<||Srrrrrr setdefaultsz_Environ.setdefaultN) __name__ __module__ __qualname__rrrrrrrrrrrrrrs  rcCsdSrr)rrrrrrrcCs t|dS)N)_putenvrrrrrrrcstdkrHdd}|t}fdd}i}tD]\}}||||<q0n(tfddfdd }}t}t||||ttS) Nr*cSs t|tstdt|j|S)Nstr expected, not %s)rRr.rtyperrrrr check_strs z!_createenviron..check_strcs |Sr)upperr)encoderrrsz!_createenviron..encodekeycs(t|tstdt|j|dS)Nrsurrogateescape)rRr.rrrrrencodingrrrs z_createenviron..encodecs |dS)Nr)decoderrrrrsz_createenviron..decode) r r.rrsysgetfilesystemencodingrr _unsetenv)rrrrrrr)rrr_createenvirons*   rcCs t||Sr)rrrdefaultrrrgetenvsr)rrcCs t|tstdt|j|S)Nzbytes expected, not %s)rRrSrrrrrrr _check_bytess rcCs t||Sr)environbrrrrrgetenvbsr)rrcs4ttfdd}fdd}||fS)Ncs&t|}t|tr|S|SdSr)r^rRr.rfilenamererrorsrrr s  z_fscodec..fsencodecs&t|}t|tr|S|SdSr)r^rRrSrrrrrr,s  z_fscodec..fsdecode)rrgetfilesystemencodeerrors)rrrrr_fscodecs   rforkspawnvrP_WAITP_NOWAIT P_NOWAITOcCst|ttfstd|r"|ds*tdt}|spz$|dkrJ|||n ||||WqtdYqXnR|tkr||St|d\}}t |rq|q|t |rt | St |rt |Stdq|dS)Nzargv must be a tuple or a listrz"argv first element cannot be emptyz"Not stopped, signaled or exited???)rRtuplerrrrr(rwaitpid WIFSTOPPED WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUSrT)rVrrrfuncpidwpidstsrrr _spawnvefIs,   rcCst|||dtSr)rrrVrrrrrrhscCst||||tSr)rrCrVrrrrrrspawnveqsr cCst|||dtSr)rrrrrrspawnvp}sr cCst||||tSr)rrrrrrspawnvpesr cGs t|||Sr)rrrrrspawnlsr cGs|d}t|||dd|Sr)r rrrrspawnlesr cGs t|||Sr)r rrrrspawnlpsrcGs|d}t|||dd|Sr)r rrrrspawnlpesrrrcCst|tstdt||dkr.td||dks>|dkrFtdddl}ddl}|dkr|j|d|j|d}t | |j |S|j|d|j|d }t | |j |SdS) Nz&invalid cmd type (%s, expected string))rwzinvalid mode %rrz+popen() does not support unbuffered streamsrT)shellstdoutbufsize)rstdinr) rRr.rrr subprocessioPopenPIPE _wrap_close TextIOWrapperrr)cmdrV bufferingrrprocrrrrs(  c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCs||_||_dSr)_stream_proc)rstreamrrrrrsz_wrap_close.__init__cCs8|j|j}|dkr dStdkr,|S|d>SdS)Nrr*)rr}r waitr )r returncoderrrr}s  z_wrap_close.closecCs|Srrrrrr __enter__sz_wrap_close.__enter__cGs |dSrr}rrrrr__exit__sz_wrap_close.__exit__cCs t|j|Sr)getattrr)rr rrr __getattr__sz_wrap_close.__getattr__cCs t|jSr)iterrrrrrrsz_wrap_close.__iter__N) rrrrr}r%r(r*rrrrrrs  rcOs4t|tstdt|ddl}|j|f||S)Nz&invalid fd type (%s, expected integer)r)rRrzrrrr:)fdrkwargsrrrrrs cCst|ttfr|St|}z||}Wn0tk rXt|drFntd|jYnXt|ttfrl|Std |jt|jdS)N __fspath__z/expected str, bytes or os.PathLike object, not z7expected {}.__fspath__() to return str or bytes, not {}) rRr.rSrr.r!r{rrr)r path_type path_reprrrr_fspaths"  r1r^c@s&eZdZejddZeddZdS)PathLikecCstdSr)NotImplementedErrorrrrrr.,szPathLike.__fspath__cCs|tkrt|dStS)Nr.)r2rNotImplemented)clssubclassrrr__subclasshook__1s zPathLike.__subclasshook__N)rrrabcabstractmethodr. classmethodr7rrrrr2(s r2c@s4eZdZddZddZddZddZd d Zd S) _AddedDllDirectorycCs||_||_||_dSr)r _cookie_remove_dll_directory)rr cookieZremove_dll_directoryrrrr:sz_AddedDllDirectory.__init__cCs||jd|_dSr)r=r<r rrrrr}>s z_AddedDllDirectory.closecCs|Srrrrrrr%Asz_AddedDllDirectory.__enter__cGs |dSrr&r'rrrr(Csz_AddedDllDirectory.__exit__cCs|jrd|jSdS)Nzz)r rrrrrrEs z_AddedDllDirectory.__repr__N)rrrrr}r%r(rrrrrr;9s r;cCs ddl}||}t|||jS)Nr)r*Z_add_dll_directoryr;r=)r r*r>rrradd_dll_directoryJs  r?)rKF)TNF)rtTN)N)N)N)N)rr)gr8rr4r~_collections_abcrbuiltin_module_namesZ_namesr rr$r rr%r(rb ImportError posixpathr r)extendr*ZntpathmodulesZos.pathrrrrr rrr rr+r0setr,supports_dir_fdsupports_effective_idsr- supports_fdsupports_follow_symlinksr rrrPrZr]rfr:rBrrrrrrrrrrrrrr NameErrorrrrrrrrrrSrrrrrrrrrrr r r r r rrrrrr1r^rABCr2r;r?rrrrs      (                                              08    - 7