Yf?:&@s dZddlZddlZddlZddlZddlTdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)g&Zd*Zd+Zd*Zd,Z d-Z d.Z dZ d/Z d0d1Zd2dZd3dZd4dZd5dZd6d Zejje_d7dZd8d Zd9d Zd:dZd;dZd<dZd=dZdadad>dZd?dZd@dZ dAd&Z!dBdCZ"ej#dDkZ$ddEd(Z%dFd)Z&dS)GaCommon 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. N)*normcaseisabsjoin splitdrivesplitsplitextbasenamedirname commonprefixgetsizegetmtimegetatimegetctimeislinkexistslexistsisdirisfileismount expanduser expandvarsnormpathabspathsamefile sameopenfilesamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath commonpath.z../:z:/bin:/usr/binz /dev/nullcCst|trdSdSdS)N/r*) isinstancebytes)pathr0./opt/alt/python35/lib64/python3.5/posixpath.py_get_sep'sr2cCs4t|ttfs0tdj|jj|S)z6Normalize case of pathname. Has no effect under Posixz2normcase() argument must be str or bytes, not '{}')r-r.str TypeErrorformat __class____name__)sr0r0r1r2s cCst|}|j|S)zTest whether a path is absolute)r2 startswith)r8rr0r0r1r=s c Gst|}|}yv|s-|dd|xW|D]O}|j|rR|}q4| sh|j|ru||7}q4|||7}q4WWn1tttfk rtjd||YnX|S)zJoin two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.Nrr)r2r9endswithr4AttributeError BytesWarning genericpath_check_arg_types)aprr/br0r0r1rGs    cCsut|}|j|d}|d|||d}}|rk||t|krk|j|}||fS)zSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.N)r2rfindlenrstrip)r@riheadtailr0r0r1rcs  !cCs@t|trd}d}n d}d}tj||d|S)Nr,.r*r))r-r.r= _splitext)r@rr#r0r0r1rss  cCs|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr0)r@r0r0r1rscCs-t|}|j|d}||dS)z)Returns the final component of a pathnamerBN)r2rC)r@rrFr0r0r1r s cCs^t|}|j|d}|d|}|rZ||t|krZ|j|}|S)z-Returns the directory component of a pathnamerBN)r2rCrDrE)r@rrFrGr0r0r1r s  c CsBytj|}Wnttfk r1dSYnXtj|jS)z&Test whether a path is a symbolic linkF)oslstatOSErrorr;statS_ISLNKst_mode)r/str0r0r1rs  c Cs.ytj|Wntk r)dSYnXdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)rKrLrM)r/r0r0r1rs   cCsytj|}Wntk r+dSYnXtj|jrBdSt|trct|d}nt|d}t |}ytj|}Wntk rdSYnX|j }|j }||krdS|j }|j }||krdSdS)z$Test whether a path is a mount pointFs..z..T) rKrLrMrNrOrPr-r.rr%st_devst_ino)r/s1parents2dev1dev2ino1ino2r0r0r1rs.           c Cs|t|trd}nd}|j|s1|St|}|j|d}|dkrgt|}|dkrdtjkrddl}|j tj j }q(tjd}noddl}|d|}t|trt |d}y|j |}Wntk r|SYnX|j }t|trOtj|}d}nd }|j|}|||dp{|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~rBrHOMENASCIIr,r*)r-r.r9r2findrDrKenvironpwdgetpwuidgetuidpw_dirr3getpwnamKeyErrorfsencoderE) r/tilderrFrauserhomenamepwentrootr0r0r1rs:           c Cst|trpd|kr|StsFddl}|jd|jatj}d}d}ttdd}nUd|kr|St sddl}|jd |ja t j}d }d }tj }d}x|||}|sP|j d\}}|j d } | j |r6| j|r6| d d } y<|dkrgtjtj tj| } n || } Wntk r|}YqX||d} |d|| }t|}|| 7}qW|S)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.$rNs\$(\w+|\{[^}]*\}){}environb$z\$(\w+|\{[^}]*\}){}rB)r-r. _varprogbrecompiler^searchgetattrrK_varprogr`spangroupr9r:rgfsdecoderfrD) r/rvrxstartendr`rFmjrjvaluerHr0r0r1r sN        "   c CsRt|tr*d}d}d}d}nd}d}d}d}||krR|S|j|}|r|j|d r|j|d  rd }|j|}g}xs|D]k}|||fkrq||ks| r| s|r |d |kr |j|q|r|jqW|}|j|}|rH|||}|pQ|S) z0Normalize path, eliminating double slashes, etc.r,rIs..r*r)z..rBrt)r-r.r9rappendpopr) r/remptydotdotdotinitial_slashescomps new_compscompr0r0r1r?s<  ' cCsOt|sEt|tr*tj}n tj}t||}t|S)zReturn an absolute path.)rr-r.rKgetcwdbgetcwdrr)r/cwdr0r0r1rds   cCs,t|dd|i\}}t|S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr) _joinrealpathr)filenamer/okr0r0r1r%rs"c Cst|tr$d}d}d}nd}d}d}t|rX|dd}|}x0|r|j|\}}}| s[||krq[||kr|rt|\}}||krt|||}q[|}q[t||}t|s|}q[||kr9||}|dk r&q[t||dfSd||s zrelpath..cSsg|]}|r|qSr0r0)rrr0r0r1rs r') ValueErrorr-r.rrrDr rr4r;r<DeprecationWarningr=r>) r/r~rrr start_list path_listrFrel_listr0r0r1r's,   ""%c s{|stdt|dtr4ddn ddy fdd|D}y&tfd d |D\}Wn!tk rtd d YnXfd d|D}t|}t|}|}x;t|D]-\}}|||kr|d |}PqW|r'n d d}|j|SWn+tt fk rvt j d|YnXd S)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr,rIr*r)csg|]}|jqSr0)r)rr/)rr0r1rs zcommonpath..c3s%|]}|ddkVqdS)NrBr0)rr@)rr0r1 szcommonpath..z%Can't mix absolute and relative pathsNcs)g|]}fdd|DqS)cs(g|]}|r|kr|qSr0r0)rc)rr0r1rs z)commonpath...r0)rr8)rr0r1rs r() rr-r.setminmax enumeraterr4r;r=r>) paths split_pathsrrTrVcommonrFrprefixr0)rrr1r(s4  &   )'__doc__rKsysrNr=__all__rrr#rr r!r"r$r2rrrrrrJrr r rrrrrzrurrrr%rplatformr&r'r(r0r0r0r1 sZ             * * 4 %   3&