³ņ Ä•Gc@sĮdZddkZddkZeiZddddddd d d d d ddg Zd„ZdejordZdZddk Tyddk l Z Wne j onXddk Z ddk Z eiee ƒƒ[ n¾dejordZdZddkTyddkl Z Wne j onXddkZ ddkZeieeƒƒ[n?dejo«dZdZddkTyddkl Z Wne j onXeiidƒdjoddkZ nddkZ ddklZddkZeieeƒƒ[n‡dejordZdZddkTyddkl Z Wne j onXddkZ ddkZeieeƒƒ[ndejordZdZddkTyddkl Z Wne j onXddkZ ddkZeieeƒƒ[n‰dejordZdZddkTyddkl Z Wne j onXddkZ ddkZeieeƒƒ[n e d‚e eidfd=„ƒYZ=nd<e:i>fd>„ƒYZ=e=e0ƒZ0dd?„Z?ei/d@ƒdA„Z@e@dBƒo\e@dCƒ oNe@dDƒoAd!ZAd"ZBZCdE„ZDdF„ZEdG„ZFdH„ZGdI„ZHne@dCƒo/dJ„ZIdK„ZJeidCdLdMdNgƒne@dOƒo/dP„ZKdQ„ZLeidOdRdSdTgƒne@dBƒo‹e@dUƒp dVddW„ZMei/dUƒne@dXƒp dVddY„ZNei/dXƒne@dZƒp dVdd[„ZOei/dZƒqnddkPZQd\„ZRd]„ZSyeQiTeUeSeRƒWne1j onXd^„ZVd_„ZWyeQiTeXeWeVƒWne1j onXe@d`ƒp da„ZYndS(ds˜OS routines for Mac, NT, or Posix depending on what system we're on. This exports: - all functions from posix, nt, os2, mac, or ce, e.g. unlink, stat, etc. - os.path is one of the modules posixpath, ntpath, or macpath - os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos' - os.curdir is a string representing the current directory ('.' or ':') - os.pardir is a string representing the parent directory ('..' or '::') - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\') - os.extsep is the extension separator ('.' or '/') - 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). i’’’’NtaltseptcurdirtpardirtseptpathseptlineseptdefpathtnametpathtdevnulltSEEK_SETtSEEK_CURtSEEK_ENDcCseyt|iƒSWnMtj oAg}t|ƒD]"}|ddjo ||q3q3~SnXdS(Nit_(tlistt__all__tAttributeErrortdir(tmodulet_[1]tn((sos.pyct_get_exports_list#stposixs (t*(t_exittnts tos2sEMX GCC(tlinktmacs tcetriscossno os specific module foundsos.path(RRRRRtextsepRR iiii’cCsĮti|ƒ\}}|pti|ƒ\}}n|ot|omti|ƒ o\yt||ƒWn/tj o#}|itijo‚q—nX|tjodSq°nt||ƒdS(smakedirs(path [, mode=0777]) 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. This is recursive. N( RtsplittexiststmakedirstOSErrorterrnotEEXISTRtmkdir(Rtmodetheadttailte((sos.pycR"–s    cCs“t|ƒti|ƒ\}}|pti|ƒ\}}nxM|oE|o>yt|ƒWntj oPnXti|ƒ\}}qBWdS(s¬removedirs(path) 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(trmdirRR terror(RR(R)((sos.pyct removedirs­s cCsžti|ƒ\}}|o&|oti|ƒ ot|ƒnt||ƒti|ƒ\}}|o/|o(yt|ƒWqštj oqšXndS(s@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 way 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(RR R!R"trenameR-R,(toldtnewR(R)((sos.pyctrenamesĆs R"R-R1c cs>ddkl}l}l}yt|ƒ}Wn4tj o(}|dj o||ƒndSnXgg}} xB|D]:} |||| ƒƒo|i| ƒqw| i| ƒqwW|o||| fVnxP|D]H} ||| ƒ} || ƒp&x#t| ||ƒD] } | Vq WqÕqÕW|p||| fVndS(se 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 (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 is ineffective, since the directories in dirnames have already been generated by the time dirnames itself is generated. By default errors from the os.listdir() call are ignored. If optional arg 'onerror' is specified, it should be a function; it will be called with one argument, an os.error 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. 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: from os.path import join, getsize for root, dirs, files in walk('python/Lib/email'): print root, "consumes", print sum([getsize(join(root, name)) for name in files]), print "bytes in", len(files), "non-directory files" if 'CVS' in dirs: dirs.remove('CVS') # don't visit CVS directories i’’’’(tjointisdirtislinkN( tos.pathR2R3R4tlistdirR,tNonetappendtwalk( ttopttopdowntonerrorR2R3R4tnamesterrtdirstnondirsRRtx((sos.pycR9ßs04    R9cGst||ƒdS(spexecl(file, *args) Execute the executable file with argument list args, replacing the current process. N(texecv(tfiletargs((sos.pyctexecl<scGs"|d}t||d |ƒdS(sŠexecle(file, *args, env) Execute the executable file with argument list args and environment env, replacing the current process. i’’’’N(texecve(RCRDtenv((sos.pyctexecleCs cGst||ƒdS(s•execlp(file, *args) Execute the executable file (which is searched for along $PATH) with argument list args, replacing the current process. N(texecvp(RCRD((sos.pyctexeclpKscGs"|d}t||d |ƒdS(s³execlpe(file, *args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env, replacing the current process. i’’’’N(texecvpe(RCRDRG((sos.pyctexeclpeRs cCst||ƒdS(sæexecp(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(t_execvpe(RCRD((sos.pycRI[scCst|||ƒdS(sßexecvpe(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. N(RM(RCRDRG((sos.pycRKcsRERHRJRLRIRKcCsk|dj ot}||f}nt}|f}t}ti|ƒ\}}|o|||ŒdSnd|jo|d}nt}|itƒ}d} d} xœ|D]”} ti| |ƒ} y|| |ŒWq¬t j o\} t i ƒd}| i t i jo0| i t ijo| djo| } |} q@q¬Xq¬W| ot | | ‚nt | |‚dS(NtPATHi(R7RFRBtenvironRR RRR2R,tsystexc_infoR$tENOENTtENOTDIR(RCRDRGtfunctargrestR(R)tenvpathRNt saved_exctsaved_tbRtfullnameR*ttb((sos.pycRMns<    & cCst|dƒdS(Nt(tputenv(tkey((sos.pyctunsetenvžs(t_EnvironR_cBs†eZd„Zd„Zd„ZyeWnej od„Zn Xd„Zd„Zd„Z d d„Z d d„Z d „Z RS( cCsJtii|ƒ|i}x*|iƒD]\}}|||iƒ 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(RŠR7RB(R'RCRD((sos.pycR+scCst||||tƒS(s: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. (RŠRF(R'RCRDRG((sos.pyctspawnve4scCst|||dtƒS(s8spawnvp(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(RŠR7RI(R'RCRD((sos.pyctspawnvp@scCst||||tƒS(s\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. (RŠRK(R'RCRDRG((sos.pyctspawnvpeJscGst|||ƒS(sspawnl(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. (R(R'RCRD((sos.pyctspawnlXscGs!|d}t|||d |ƒS(s: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. i’’’’(R‹(R'RCRDRG((sos.pyctspawnleas R‹RŽRRŒcGst|||ƒS(sWspawnlp(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. (RŒ(R'RCRD((sos.pyctspawnlpsscGs!|d}t|||d |ƒS(s]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. i’’’’(R(R'RCRDRG((sos.pyctspawnlpe}s RRR‘tpopen2ttcCs.ddk}|i||ƒ\}}||fS(sĻExecute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If 'cmd' is a string it will be passed to the shell (as with os.system()). If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdin, child_stdout) are returned.i’’’’N(R’(tcmdR'tbufsizeR’tstdouttstdin((sos.pycR’s tpopen3cCs4ddk}|i||ƒ\}}}|||fS(sŻExecute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If 'cmd' is a string it will be passed to the shell (as with os.system()). If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdin, child_stdout, child_stderr) are returned.i’’’’N(R’R˜(R”R'R•R’R–R—tstderr((sos.pycR˜œs tpopen4cCs.ddk}|i||ƒ\}}||fS(sÖExecute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If 'cmd' is a string it will be passed to the shell (as with os.system()). If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdin, child_stdout_stderr) are returned.i’’’’N(R’Rš(R”R'R•R’R–R—((sos.pycRš©s cCs t||ƒS(N(t stat_result(ttupRr((sos.pyct_make_stat_result·scCs|iƒ\}}t|fS(N(t __reduce__R(tsrttypeRD((sos.pyct_pickle_stat_resultŗscCs t||ƒS(N(tstatvfs_result(RœRr((sos.pyct_make_statvfs_resultĆscCs|iƒ\}}t|fS(N(RžR£(RŸR RD((sos.pyct_pickle_statvfs_resultĘsturandomc Cs‡ytdtƒ}Wn%ttfj otdƒ‚nXd}x5t|ƒ|jo!|t||t|ƒƒ7}qDWt|ƒ|S(sfurandom(n) -> str Return a string of n random bytes suitable for cryptographic use. s /dev/urandoms&/dev/urandom (or equivalent) not foundR[(topentO_RDONLYR#tIOErrortNotImplementedErrortlentreadtclose(Rt _urandomfdtbytes((sos.pycR„Ńs" (sos2snt(sos2snt(Zt__doc__RPR$tbuiltin_module_namest_namesRRRRRRt ImportErrort posixpathRtextendRtntpathRtversiontfindt os2emxpatht _emx_linkRRtmacpathRRt riscospathtmodulesR5RRRRRRRR R R R R"R-R1R{R7R9R8RORwRERHRJRLRIRKRMR\R`R^t riscosenvironR_tIterableUserDictRyR}tP_WAITR€t P_NOWAITORŠRR‹RŒRRŽRRR‘R’R˜Rštcopy_regt _copy_regRR”tpickleR›R£R¤R¢R„(((sos.pycssH                             :   U        #     .#    (