o bc@shdZddlZddlZddlZddlmZeee Z ej Z gdZ ddZddZd e vrod Zd Zdd lTz dd lmZe d Wn eyKYnwddlZzddlmZWn eyaYnwddlZe ee[nIde vrdZdZdd lTz dd lmZe d Wn eyYnwddlZddlZe ee[zddlmZWn eyYnwedeejd<ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%[ edre&Z'ddZ(e)Z*e(dde(dde(dde(dde(dd e(d!d"e(d#d$e(d%d&e(d'd(e(d)d*e(d+d,e(d-d.e(d/d0e(d1d2e(d1d3e(d4d e*Z+e)Z*e(dde*Z,e)Z*e(d5d6e(d7de(d8de(d9d:e(d9d;e(dd?e(d@d e(dAd e(dBdCedDredEre(dFdDe*Z.e)Z*e(dde(dde(dde(dGdHe(dIdedJre(dKde(d!d"e(dLd e(dMde(dde(d4d e(dNde*Z/[*[['[(dZ0dOZ1dPZ2ddSdTZ3dUdVZ4dWdXZ5e gdYdd[d\Z6d]d^Z7e d\e8ehe+kre9ehe.krddRdd`dadbZ:dcddZ;e dbdedfZdkdlZ?dmdnZ@dodpZAe gdqddrdsZBddtduZCddvlmDZDmEZEGdwdxdxeDZFdydzZGeGZH[Gdd{d|ZIedkZJe d}eJrd~dZKeFeHjLeKeMeKeMZN[KdddZOe dddZPeP\ZQZR[PedredsedrdZSdOZTZUe gdddZVddZWddZXddZYddZZe gdedrddZ[ddZ\e ddgedrddZ]ddZ^e ddgej_dkrdddZ`GdddZae ddddZbddZcedsecZdded_eGdddejfZgedkr2GdddZhddZidSdS)aNOS routines for NT or Posix depending on what system we're on. This exports: - all functions from posix or nt, e.g. unlink, stat, etc. - os.path is either posixpath or ntpath - os.name is either 'posix' or 'nt' - os.curdir is a string representing the current directory (always '.') - os.pardir is a string representing the parent directory (always '..') - os.sep is the (or a most common) pathname separator ('/' or '\\') - os.extsep is the extension separator (always '.') - os.altsep is the alternate pathname separator (None or '/') - os.pathsep is the component separator used in $PATH etc - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n') - os.defpath is the default search path for executables - os.devnull is the file path of the null device ('/dev/null', etc.) Programs that import and use 'os' stand a better chance of being portable between different platforms. Of course, they must then only use functions that are defined by all platforms (e.g., unlink and opendir), and leave all pathname manipulation to os.path (e.g., split and join). N)_check_methods)altsepcurdirpardirseppathseplinesepdefpathnamepathdevnullSEEK_SETSEEK_CURSEEK_ENDfsencodefsdecode get_exec_pathfdopenextsepcCs |tvSN)globals)r rc/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/os.py_exists) rcCs2zt|jWStyddt|DYSw)NcSsg|] }|ddkr|qS)r_r).0nrrr 0sz%_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*|tvr|tvrtt|dSdSdSr)_globalsr)_setadd)strfnrrr_addhsr0ZHAVE_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|\}}|st|\}}|r=|r=t|s=zt||dWn ty*Ynwt}t|tr7ttd}||kr=dSzt||WdSt yW|rSt |sTYdSw)amakedirs(name [, mode=0o777][, exist_ok=False]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. If the target directory already exists, raise an OSError if exist_ok is False. Otherwise no exception is raised. This is recursive. )exist_okZASCIIN) r splitexistsmakedirsFileExistsErrorr isinstancebytesr7OSErrorisdir)r moderLheadtailZcdirrrrrOs*     rOcCsxt|t|\}}|st|\}}|r6|r8zt|Wn ty(YdSwt|\}}|r:|sdSdSdSdS)aremovedirs(name) Super-rmdir; remove a leaf directory and all empty intermediate ones. Works like rmdir except that, if the leaf directory is successfully removed, directories corresponding to rightmost path segments will be pruned away until either the whole path is consumed or an error occurs. Errors during this latter phase are ignored -- they generally mean that a directory was not empty. N)r?r rMrS)r rVrWrrr removedirss   rXcCstt|\}}|r|rt|st|t||t|\}}|r6|r8zt|WdSty5YdSwdSdS)a<renames(old, new) Super-rename; create directories as necessary and delete any left empty. Works like rename, except creation of any intermediate directories needed to make the new pathname good is attempted first. After the rename, directories corresponding to rightmost path segments of the old name will be pruned until either the whole path is consumed or a nonempty directory is found. Note: this function can fail with the new directory structure made if you lack permissions needed to unlink the leaf directory or file. N)r rMrNrOr<rXrS)oldnewrVrWrrrrenamess  r[)rOrXr[TcCs$td||||tt||||S)a, Directory tree generator. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), yields a 3-tuple dirpath, dirnames, filenames dirpath is a string, the path to the directory. dirnames is a list of the names of the subdirectories in dirpath (including symlinks to directories, and excluding '.' and '..'). filenames is a list of the names of the non-directory files in dirpath. Note that the names in the lists are just names, with no path components. To get a full path (which begins with top) to a file or directory in dirpath, do os.path.join(dirpath, name). If optional arg 'topdown' is true or not specified, the triple for a directory is generated before the triples for any of its subdirectories (directories are generated top down). If topdown is false, the triple for a directory is generated after the triples for all of its subdirectories (directories are generated bottom up). When topdown is true, the caller can modify the dirnames list in-place (e.g., via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in dirnames; this can be used to prune the search, or to impose a specific order of visiting. Modifying dirnames when topdown is false has no effect on the behavior of os.walk(), since the directories in dirnames have already been generated by the time dirnames itself is generated. No matter the value of topdown, the list of subdirectories is retrieved before the tuples for the directory and its subdirectories are generated. By default errors from the os.scandir() call are ignored. If optional arg 'onerror' is specified, it should be a function; it will be called with one argument, an OSError instance. It can report the error to continue with the walk, or raise the exception to abort the walk. Note that the filename is available as the filename attribute of the exception object. By default, os.walk does not follow symbolic links to subdirectories on systems that support them. In order to get this functionality, set the optional argument 'followlinks' to true. Caution: if you pass a relative pathname for top, don't change the current working directory between resumptions of walk. walk never changes the current directory, and assumes that the client doesn't either. Example: import os from os.path import join, getsize for root, dirs, files in os.walk('python/Lib/email'): print(root, "consumes", end="") print(sum(getsize(join(root, name)) for name in files), end="") print("bytes in", len(files), "non-directory files") if 'CVS' in dirs: dirs.remove('CVS') # don't visit CVS directories zos.walk)sysaudit_walkfspath)toptopdownonerror followlinksrrrwalks<rdc csg}g}g}zt|}Wnty(}z|dur||WYd}~dSd}~ww| zzt|} Wn ty>YWnlwWn!tya}z|durP||WYd}~WddSd}~wwz| } Wn tysd} Ynw| r}|| jn|| j|s| r|rd} nz| } Wn tyd} Ynw| } | r|| jq-Wdn1swY|r|||fVtj tj } }|D]}|||}|s| |st ||||EdHqdS|D] }t ||||EdHq|||fVdS)NTF) rBrSnext StopIterationis_dirappendr is_symlinkr islinkjoinr^)r`rarbrcdirsnondirsZ walk_dirs scandir_iterrorentryrgZ walk_intorirjrkdirnameZnew_pathrrrr^Ys|          +    r^.follow_symlinksdir_fdccstd|||||t|trt|dst|}|s"t|d|d}t|t|d}z4|s:t |j rPt |t|rWt||t|t|||EdHWt|dSWt|dSWt|dSt|w)aDirectory tree generator. This behaves exactly like walk(), except that it yields a 4-tuple dirpath, dirnames, filenames, dirfd `dirpath`, `dirnames` and `filenames` are identical to walk() output, and `dirfd` is a file descriptor referring to the directory `dirpath`. The advantage of fwalk() over walk() is that it's safe against symlink races (when follow_symlinks is False). If dir_fd is not None, it should be a file descriptor open to a directory, and top should be relative; top will then be relative to that directory. (dir_fd is always supported for fwalk.) Caution: Since fwalk() yields file descriptors, those are only valid until the next iteration step, so you should dup() them if you want to keep them for a longer period. Example: import os for root, dirs, files, rootfd in os.fwalk('python/Lib/email'): print(root, "consumes", end="") print(sum(os.stat(name, dir_fd=rootfd).st_size for name in files), end="") print("bytes in", len(files), "non-directory files") if 'CVS' in dirs: dirs.remove('CVS') # don't visit CVS directories zos.fwalk __index__FrsruN)r\r]rQinthasattrr_r4r:O_RDONLYstZS_ISDIRst_moder samestat_fwalkrRclose)r`rarbrtruorig_sttopfdrrrfwalks&!  rc cst|}g}g}|s |rdng} |D]C} | j} |rt| } z| r2|| | dur1| | n|| WqtyVz | rI|| Wn tySYnwYqw|r`||||fV| durf|nt|| D]i} z%|s|rzt| |dd} n| dusJ| \} } | jdd} t | t |d} Wnty}z|dur||WYd}~qkd}~wwz"|st | t| rt || }t| |||||EdHWt| qkt| w|s||||fVdSdS)NF)rurt)rtrw)rBr rrgrhrSrizipr4r:rzr r}rkr~r)rZtoppathZisbytesrarbrtrnrlrmZentriesrpr rZdirfderrdirpathrrrr~sn           r~cGt||dS)zpexecl(file, *args) Execute the executable file with argument list args, replacing the current process. N)execvfileargsrrrexeclrcG |d}t||dd|dS)zexecle(file, *args, env) Execute the executable file with argument list args and environment env, replacing the current process. N)rCrrenvrrrexecle!srcGr)zexeclp(file, *args) Execute the executable file (which is searched for along $PATH) with argument list args, replacing the current process. N)execvprrrrexeclp)rrcGr)zexeclpe(file, *args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env, replacing the current process. rN)execvperrrrexeclpe0srcCr)zexecvp(file, args) Execute the executable file (which is searched for along $PATH) with argument list args, replacing the current process. args may be a list or tuple of strings. N_execvperrrrr9srcCst|||dS)zexecvpe(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env, replacing the current process. args may be a list or tuple of strings. NrrrrrrAr)rrrrrrc Cs|dur t}||f}nt}|f}t}t|r!||g|RdSd}t|}tdkr4t|}tt|}|D]A}t ||}z ||g|RWq6t t fy^} z| } WYd} ~ q6d} ~ wt yw} z| } |durm| }WYd} ~ q6d} ~ ww|dur~|| )Nr*) rCrenvironr rqrr rmaprkFileNotFoundErrorNotADirectoryErrorrS) rrrZ exec_funcZargrestZ saved_exc path_listr"fullnameeZlast_excrrrrLs<    rc Csddl}|dur t}|L|dtz|d}Wn ty'd}YnwtrSz|d}Wn ttfy;Yn w|durDt d|}|durSt |t rSt |}Wdn1s]wY|durht }|tS)zReturns the sequence of directories that will be searched for the named executable (similar to a shell) when launching a process. *env* must be an environment variable dict or None. If *env* is None, os.environ will be used. rNignoreZPATHsPATHz*env cannot contain 'PATH' and b'PATH' keys)warningsrcatch_warnings simplefilter BytesWarningget TypeErrorsupports_bytes_environKeyError ValueErrorrQrRrr rMr)rrrZ path_listbrrrrls8      r)MutableMappingMappingc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS)_EnvironcCs"||_||_||_||_||_dSr) encodekey decodekey encodevalue decodevalue_data)selfdatarrrrrrr__init__s  z_Environ.__init__cCs8z |j||}Wn tyt|dw||Sr)rrrrrkeyvaluerrr __getitem__s    z_Environ.__getitem__cCs,||}||}t||||j|<dSr)rrputenvrrrrr __setitem__s   z_Environ.__setitem__cCs:||}t|z|j|=WdStyt|dwr)runsetenvrr)rrZ encodedkeyrrr __delitem__s   z_Environ.__delitem__ccs&t|j}|D]}||VqdSr)rrr)rkeysrrrr__iter__s  z_Environ.__iter__cC t|jSr)lenrrrrr__len__rz_Environ.__len__cs$ddfddjDS)Nzenviron({{{}}})z, c3s,|]\}}d||VqdS)z {!r}: {!r}N)formatrr)rrrrrr s z$_Environ.__repr__..)rrkritemsrrrr__repr__s  z_Environ.__repr__cCst|Sr)dictrrrrcopysz _Environ.copycCs||vr|||<||Srrrrrr setdefaultsz_Environ.setdefaultcCs|||Sr)update)rotherrrr__ior__s z_Environ.__ior__cCs$t|tstSt|}|||SrrQrNotImplementedrrrrrZrrr__or__  z_Environ.__or__cCs$t|tstSt|}|||Srrrrrr__ror__rz_Environ.__ror__N)__name__ __module__ __qualname__rrrrrrrrrrrrrrrrrs  rcstdkr$dd}|t}fdd}i}tD] \}}||||<qntfddfdd }}t}t||||S) Nr*cS t|tstdt|j|S)Nstr expected, not %s)rQr.rtyperrrrr check_str z!_createenviron..check_strcs |Sr)upper)r)encoderrr z!_createenviron..encodekeycs(t|tstdt|j|dS)Nrsurrogateescape)rQr.rrrrrencodingrrrs  z_createenviron..encodecs |dS)Nr)decoderrrrrrz_createenviron..decode)r r.rrr\getfilesystemencodingr)rrrrrrr)rrr_createenvirons$   rcC t||S)zGet an environment variable, return None if it doesn't exist. The optional second argument can specify an alternate default. key, default and the result are str.)rrrdefaultrrrgetenv r)rrcCr)Nzbytes expected, not %s)rQrRrrrrrrr _check_bytesrrcCr)zGet an environment variable, return None if it doesn't exist. The optional second argument can specify an alternate default. key, default and the result are bytes.)environbrrrrrgetenvbrr)rrcs4ttfdd}fdd}||fS)Nc"t|}t|tr|S|S)aEncode filename (an os.PathLike, bytes, or str) to the filesystem encoding with 'surrogateescape' error handler, return bytes unchanged. On Windows, use 'strict' error handler if the file system encoding is 'mbcs' (which is the default encoding). )r_rQr.rfilenamererrorsrrr%  z_fscodec..fsencodecr)aDecode filename (an os.PathLike, bytes, or str) from the filesystem encoding with 'surrogateescape' error handler, return str unchanged. On Windows, use 'strict' error handler if the file system encoding is 'mbcs' (which is the default encoding). )r_rQrRrrrrrr1rz_fscodec..fsdecode)r\rgetfilesystemencodeerrors)rrrrr_fscodec!s   rforkspawnvr)P_WAITP_NOWAIT P_NOWAITOcCst|ttfs td|r|dstdt}|s;z|dur%|||n ||||WdSWdStdYdS|tkrA|S t|d\}}t |rNqAt |S)Nzargv must be a tuple or a listrz"argv first element cannot be empty) rQtuplerrrrr(rwaitpid WIFSTOPPEDwaitstatus_to_exitcode)rUrrrfuncZpidZwpidZstsrrr _spawnvefNs(  rcCt|||dtS)aspawnv(mode, file, args) -> integer Execute file with arguments from args in a subprocess. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. N)rrrUrrrrrrircCt||||tS)a:spawnve(mode, file, args, env) -> integer Execute file with arguments from args in a subprocess with the specified environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. )rrCrUrrrrrrspawnverrcCr)a8spawnvp(mode, file, args) -> integer Execute file (which is looked for along $PATH) with arguments from args in a subprocess. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. N)rrrrrrspawnvp~rrcCr)a\spawnvpe(mode, file, args, env) -> integer Execute file (which is looked for along $PATH) with arguments from args in a subprocess with the supplied environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. )rrrrrrspawnvperr)rrrrcG t|||S)aspawnl(mode, file, *args) -> integer Execute file with arguments from args in a subprocess. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. )rrrrrspawnls r cG|d}t|||dd|S)a:spawnle(mode, file, *args, env) -> integer Execute file with arguments from args in a subprocess with the supplied environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. rN)rrrrrspawnler cGr )aWspawnlp(mode, file, *args) -> integer Execute file (which is looked for along $PATH) with arguments from args in a subprocess with the supplied environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. )rrrrrspawnlps rcGr )a]spawnlpe(mode, file, *args, env) -> integer Execute file (which is looked for along $PATH) with arguments from args in a subprocess with the supplied environment. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. rN)rrrrrspawnlper rvxworksrrcCst|ts tdt||dvrtd||dks|dur#tdddl}ddl}|dkr@|j|dd|j|d}t |j |S|j|dd|j|d }t |j |S) Nz&invalid cmd type (%s, expected string))rwzinvalid mode %rrz+popen() does not support unbuffered streamsrT)shelltextstdoutbufsize)rrstdinr) rQr.rrr subprocessioZPopenZPIPE _wrap_closerr)ZcmdrU bufferingrrprocrrrpopens(    rc@s<eZdZddZddZddZddZd d Zd d Zd S)rcCs||_||_dSr)_stream_proc)rstreamrrrrrs z_wrap_close.__init__cCs4|j|j}|dkrdStdkr|S|d>S)Nrr*)rrrwaitr )rZ returncoderrrrs  z_wrap_close.closecC|Srrrrrr __enter__z_wrap_close.__enter__cG |dSrrrrrrr__exit__rz_wrap_close.__exit__cCs t|j|Sr)getattrr)rr rrr __getattr__rz_wrap_close.__getattr__cCrr)iterrrrrrrrz_wrap_close.__iter__N) rrrrrr$r)r+rrrrrrs  rcOsRt|ts tdt|ddl}d|vr||}|j||||g|Ri|S)Nz&invalid fd type (%s, expected integer)rb)rQrxrrr text_encodingr:)fdrUrrrkwargsrrrrrs  rcCs|t|ttfr |St|}z||}Wnty(t|dr!td|jwt|ttfr2|Std |jt|j)aaReturn the path representation of a path-like object. If str or bytes is passed in, it is returned unchanged. Otherwise the os.PathLike interface is used to get the path representation. If the path representation is not str or bytes, TypeError is raised. If the provided path is not str, bytes, or os.PathLike, TypeError is raised. __fspath__z/expected str, bytes or os.PathLike object, not z7expected {}.__fspath__() to return str or bytes, not {}) rQr.rRrr1r!ryrrr)r Z path_typeZ path_reprrrr_fspath s&  r2r_c@s2eZdZdZejddZeddZee Z dS)PathLikezCAbstract base class for implementing the file system path protocol.cCst)z9Return the file system path representation of the object.)NotImplementedErrorrrrrr13szPathLike.__fspath__cCs|tur t|dStS)Nr1)r3rr)clssubclassrrr__subclasshook__8s zPathLike.__subclasshook__N) rrr__doc__abcabstractmethodr1 classmethodr7 GenericAlias__class_getitem__rrrrr3/s   r3c@s4eZdZddZddZddZddZd d Zd S) _AddedDllDirectorycCs||_||_||_dSr)r _cookie_remove_dll_directory)rr cookieZremove_dll_directoryrrrrCs z_AddedDllDirectory.__init__cCs||jd|_dSr)r@r?r rrrrrGs  z_AddedDllDirectory.closecCr#rrrrrrr$Jr%z_AddedDllDirectory.__enter__cGr&rr'r(rrrr)Lrz_AddedDllDirectory.__exit__cCs|jr d|jSdS)Nzz)r rrrrrrNs z_AddedDllDirectory.__repr__N)rrrrrr$r)rrrrrr>Bs  r>cCs ddl}||}t|||jS)aOAdd a path to the DLL search path. This search path is used when resolving dependencies for imported extension modules (the module itself is resolved through sys.path), and also by ctypes. Remove the directory by calling close() on the returned object or using it in a with statement. rN)r*Z_add_dll_directoryr>r@)r r*rArrradd_dll_directorySs rB)rKF)TNF)rrTNr)rr)rrN)jr8r9r\r4r{Z_collections_abcrrrrxr<builtin_module_namesZ_namesr rr$r rr%r(rh ImportErrorZ posixpathr r)extendr*ZntpathmodulesZos.pathrrrrr rrr rr+r0setr,Zsupports_dir_fdZsupports_effective_idsr-Z supports_fdZsupports_follow_symlinksr rrrOrXr[rdr^r:rBrr~rrrrrrrrrrrrrrrrrrRrrrrrrrrrrrrrr r rrplatformrrrr2r_rABCr3r>rBrrrrsr         (                                              ? R1 8   -G