³ò Ä•Gc'@sØdZddkZddkZddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'g%Zd(Zd)Zd(Zd*Zd+Zd,Z dZ d-Z d.„Z d/„Zd0„Zd1„Zd2„Zd3„Zd4„Zd5„Zd6„Zd7„Zd8„Zd9„Zd:„Zd;„Zd<„Zd=„Zd>„Zd?„Zd@„ZdA„Z dB„Z!dC„Z"dD„Z#dE„Z$da%dF„Z&dG„Z'dH„Z(dI„Z)dJ„Z*e+Z,dS(KsçCommon operations on Posix pathnames. Instead of importing this module directly, import os and refer to this module as os.path. The "os.path" name is an alias for this module on Posix systems; on other systems (e.g. Mac, Windows), os.path provides the same operations in a manner specific to that platform, and is an alias to another module (e.g. macpath, ntpath). Some of this can actually be useful on non-Posix systems too, e.g. for manipulation of the pathname component of URLs. iÿÿÿÿNtnormcasetisabstjoint splitdrivetsplittsplitexttbasenametdirnamet commonprefixtgetsizetgetmtimetgetatimetgetctimetislinktexiststlexiststisdirtisfiletismounttwalkt expandusert expandvarstnormpathtabspathtsamefilet sameopenfiletsamestattcurdirtpardirtseptpathseptdefpathtaltseptextseptdevnulltrealpathtsupports_unicode_filenamest.s..t/t:s:/bin:/usr/bins /dev/nullcCs|S(s6Normalize case of pathname. Has no effect under Posix((ts((s posixpath.pycR'scCs |idƒS(sTest whether a path is absoluteR&(t startswith(R(((s posixpath.pycR/scGsn|}xa|D]Y}|idƒo |}q |djp|idƒo||7}q |d|7}q W|S(s=Join two or more pathname components, inserting '/' as neededR&t(R)tendswith(tatptpathtb((s posixpath.pycR8s cCsc|idƒd}|| ||}}|o*|dt|ƒjo|idƒ}n||fS(s€Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.R&i(trfindtlentrstrip(R-titheadttail((s posixpath.pycRJs cCsI|idƒ}||idƒjo|dfSn|| ||fSdS(s‘Split the extension from a pathname. Extension is everything from the last dot to the end. Returns "(root, ext)", either part may be empty.R%R&R*N(R0(R-R3((s posixpath.pycRYscCs d|fS(sJSplit a pathname into drive and path. On Posix, drive is always empty.R*((R-((s posixpath.pycRfscCst|ƒdS(s)Returns the final component of a pathnamei(R(R-((s posixpath.pycRnscCst|ƒdS(s-Returns the directory component of a pathnamei(R(R-((s posixpath.pycRuscCs‚|pdSnt|ƒ}t|ƒ}tt|ƒt|ƒƒ}x5t|ƒD]'}||||jo || SqOqOW|| S(sGGiven a list of pathnames, returns the longest common leading componentR*(tmintmaxR1txrange(tmts1ts2tnR3((s posixpath.pycR|s   cCsti|ƒiS(s1Return the size of a file, reported by os.stat().(toststattst_size(tfilename((s posixpath.pycR ‰scCsti|ƒiS(sCReturn the last modification time of a file, reported by os.stat().(R=R>tst_mtime(R@((s posixpath.pycR scCsti|ƒiS(s=Return the last access time of a file, reported by os.stat().(R=R>tst_atime(R@((s posixpath.pycR ‘scCsti|ƒiS(sAReturn the metadata change time of a file, reported by os.stat().(R=R>tst_ctime(R@((s posixpath.pycR •scCsFyti|ƒ}Wn titfj o tSnXti|iƒS(s&Test whether a path is a symbolic link(R=tlstatterrortAttributeErrortFalseR>tS_ISLNKtst_mode(R.tst((s posixpath.pycR œs  cCs4yti|ƒ}Wntij o tSnXtS(sDTest whether a path exists. Returns False for broken symbolic links(R=R>RERGtTrue(R.RJ((s posixpath.pycR¨s  cCs4yti|ƒ}Wntij o tSnXtS(sCTest whether a path exists. Returns True for broken symbolic links(R=RDRERGRK(R.RJ((s posixpath.pycR³s  cCs@yti|ƒ}Wntij o tSnXti|iƒS(s"Test whether a path is a directory(R=R>RERGtS_ISDIRRI(R.RJ((s posixpath.pycRÀs  cCs@yti|ƒ}Wntij o tSnXti|iƒS(s%Test whether a path is a regular file(R=R>RERGtS_ISREGRI(R.RJ((s posixpath.pycRÍs  cCs+ti|ƒ}ti|ƒ}t||ƒS(s9Test whether two pathnames reference the same actual file(R=R>R(tf1tf2R:R;((s posixpath.pycRØscCs+ti|ƒ}ti|ƒ}t||ƒS(s:Test whether two open file objects reference the same file(R=tfstatR(tfp1tfp2R:R;((s posixpath.pycRâscCs#|i|ijo|i|ijS(s5Test whether two stat buffers reference the same file(tst_inotst_dev(R:R;((s posixpath.pycRìscCsšy+ti|ƒ}tit|dƒƒ}Wntij o tSnX|i}|i}||jotSn|i}|i}||jotSntS(s$Test whether a path is a mount points..(R=RDRRERGRTRKRS(R.R:R;tdev1tdev2tino1tino2((s posixpath.pycRõs       c Csºyti|ƒ}Wntij o dSnX||||ƒxs|D]k}t||ƒ}yti|ƒ}Wntij o qGnXti|iƒot|||ƒqGqGWdS(sIDirectory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding '.' and '..'). func may modify the fnames list in-place (e.g. via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.N( R=tlistdirRERRDR>RLRIR(ttoptfunctargtnamestnameRJ((s posixpath.pycRs cCs|idƒp|Sn|iddƒ}|djot|ƒ}n|djoIdtijo(ddk}|itiƒƒi}qætid}nJddk}y|i |d|!ƒ}Wnt j o |SnX|i}|i dƒ}|||S(sOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.t~R&iitHOMEiÿÿÿÿN( R)tfindR1R=tenvirontpwdtgetpwuidtgetuidtpw_dirtgetpwnamtKeyErrorR2(R.R3Rctuserhometpwent((s posixpath.pycR6s$      cCsd|jo|Sntpddk}|idƒand}xÎtoÆti||ƒ}|pPn|idƒ\}}|idƒ}|idƒo!|idƒo|dd!}n|t i jo9||}|| t i |}t |ƒ}||7}qD|}qDW|S( sZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.t$iÿÿÿÿNs\$(\w+|\{[^}]*\})iit{t}( t_varprogtretcompileRKtsearchtspantgroupR)R+R=RbR1(R.RoR3R9tjR^R5((s posixpath.pycRUs,      cCs$|djodSn|idƒ}|o+|idƒo|idƒ o d}n|idƒ}g}x}|D]u}|d joqrn|djp(| o| p|o"|ddjo|i|ƒqr|o|iƒqrqrW|}di|ƒ}|od||}n|pdS( s0Normalize path, eliminating double slashes, etc.R*R%R&s//s///is..iÿÿÿÿ(R*R%(R)RtappendtpopR(R.tinitial_slashestcompst new_compstcomp((s posixpath.pycRus, !  cCs0t|ƒpttiƒ|ƒ}nt|ƒS(sReturn an absolute path.(RRR=tgetcwdR(R.((s posixpath.pycRs cCsìt|ƒodg|idƒd}ndg|idƒ}xžtdt|ƒdƒD]ƒ}t|d|!Œ}t|ƒo]t|ƒ}|djott|g||ŒƒSqÞt|g||Œ}t |ƒSq[q[Wt|ƒS(slReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.R&iR*iiN( RRtrangeR1RR t _resolve_linktNoneRR#(R@tbitsR3t componenttresolvedtnewpath((s posixpath.pycR#šs    cCsŽg}xt|ƒos||jodSn|i|ƒti|ƒ}t|ƒp%t|ƒ}tt||ƒƒ}q t|ƒ}q W|S(sÈInternal helper function. Takes a path and follows symlinks until we either arrive at something that isn't a symlink, or encounter a path we've seen before (meaning that there's a loop). N( R R~RuR=treadlinkRRRR(R.t paths_seenRtdir((s posixpath.pycR}±s     (-t__doc__R=R>t__all__RRR!RRRR~R R"RRRRRRRRRR R R R R RRRRRRRRRRRnRRRR#R}RGR$(((s posixpath.pycs s`               '