f7c%@sdZddlZddlZddlZddlZddlTdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(g%Zd)Zd*Zd)Zd+Z d,Z d-Z dZ d.Zd/d0Zd1dZd2dZd3dZd4dZd5d Zejje_d6dZd7d Zd8d Zd9dZd:dZd;dZd<dZd=dZd>dZd?dZda da!d@dZ"dAdZ#dBdZ$dCd&Z%dDdEZ&ej'dFkZ(ddGd(Z)dS(HuCommon 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. iN(u*unormcaseuisabsujoinu splitdriveusplitusplitextubasenameudirnameu commonprefixugetsizeugetmtimeugetatimeugetctimeuislinkuexistsulexistsuisdiruisfileuismountu expanduseru expandvarsunormpathuabspathusamefileu sameopenfileusamestatucurdirupardirusepupathsepudefpathualtsepuextsepudevnullurealpathusupports_unicode_filenamesurelpathu.u..u/u:u:/bin:/usr/binu /dev/nullcCst|trdSdSdS(Ns/u/(u isinstanceubytes(upath((u./opt/alt/python33/lib64/python3.3/posixpath.pyu_get_sep&su_get_sepcCs7t|ttfs3tdj|jjn|S(u6Normalize case of pathname. Has no effect under Posixu2normcase() argument must be str or bytes, not '{}'(u isinstanceubytesustru TypeErroruformatu __class__u__name__(us((u./opt/alt/python33/lib64/python3.3/posixpath.pyunormcase1s cCst|}|j|S(uTest whether a path is absolute(u_get_sepu startswith(ususep((u./opt/alt/python33/lib64/python3.3/posixpath.pyuisabs=s c Gst|}|}y^xW|D]O}|j|r:|}q| sP|j|r]||7}q|||7}qWWnMtk rtdd|f|D}|rtddnYnX|S(uJoin 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.css'|]}t|tttfVqdS(N(u isinstanceustrubytesu bytearray(u.0us((u./opt/alt/python33/lib64/python3.3/posixpath.pyu Wsujoin..u/Can't mix strings and bytes in path components.N(u_get_sepu startswithuendswithu TypeErrorualluNone(uaupusepupathubu valid_types((u./opt/alt/python33/lib64/python3.3/posixpath.pyujoinGs"        cCsxt|}|j|d}|d|||d}}|rn||t|krn|j|}n||fS(uSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.iN(u_get_sepurfindulenurstrip(upusepuiuheadutail((u./opt/alt/python33/lib64/python3.3/posixpath.pyusplitfs  !cCs@t|trd}d}n d}d}tj||d|S(Ns/s.u/u.(u isinstanceubytesu genericpathu _splitextuNone(upusepuextsep((u./opt/alt/python33/lib64/python3.3/posixpath.pyusplitextvs  cCs|dd|fS(uJSplit a pathname into drive and path. On Posix, drive is always empty.Ni((up((u./opt/alt/python33/lib64/python3.3/posixpath.pyu splitdrivescCs-t|}|j|d}||dS(u)Returns the final component of a pathnameiN(u_get_sepurfind(upusepui((u./opt/alt/python33/lib64/python3.3/posixpath.pyubasenames cCsat|}|j|d}|d|}|r]||t|kr]|j|}n|S(u-Returns the directory component of a pathnameiN(u_get_sepurfindulenurstrip(upusepuiuhead((u./opt/alt/python33/lib64/python3.3/posixpath.pyudirnames  c CsEytj|}Wntjtfk r4dSYnXtj|jS(u&Test whether a path is a symbolic linkF(uosulstatuerroruAttributeErroruFalseustatuS_ISLNKust_mode(upathust((u./opt/alt/python33/lib64/python3.3/posixpath.pyuislinks  c Cs1ytj|Wntjk r,dSYnXdS(uCTest whether a path exists. Returns True for broken symbolic linksFT(uosulstatuerroruFalseuTrue(upath((u./opt/alt/python33/lib64/python3.3/posixpath.pyulexistss  cCs+tj|}tj|}t||S(u9Test whether two pathnames reference the same actual file(uosustatusamestat(uf1uf2us1us2((u./opt/alt/python33/lib64/python3.3/posixpath.pyusamefilescCs+tj|}tj|}t||S(u:Test whether two open file objects reference the same file(uosufstatusamestat(ufp1ufp2us1us2((u./opt/alt/python33/lib64/python3.3/posixpath.pyu sameopenfilescCs"|j|jko!|j|jkS(u5Test whether two stat buffers reference the same file(ust_inoust_dev(us1us2((u./opt/alt/python33/lib64/python3.3/posixpath.pyusamestatsc Cst|rdSyRtj|}t|trCt|d}nt|d}tj|}Wntjk r}dSYnX|j}|j}||krdS|j }|j }||krdSdS(u$Test whether a path is a mount points..u..FT( uislinkuFalseuosulstatu isinstanceubytesujoinuerrorust_devuTrueust_ino(upathus1uparentus2udev1udev2uino1uino2((u./opt/alt/python33/lib64/python3.3/posixpath.pyuismounts&        c Cst|trd}nd}|j|s1|St|}|j|d}|dkrjt|}n|dkrdtjkrddl}|j tj j }q.tjd}nrddl}|d|}t|trt |d}ny|j |}Wntk r$|SYnX|j }t|trUtj|}d}nd }|j|}|||dp|S( uOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.s~u~iiuHOMENuASCIIs/u/(u isinstanceubytesu startswithu_get_sepufindulenuosuenvironupwdugetpwuidugetuidupw_dirustrugetpwnamuKeyErrorufsencodeurstrip( upathutildeusepuiupwduuserhomeunameupwenturoot((u./opt/alt/python33/lib64/python3.3/posixpath.pyu expandusers:          c Cst|trsd|kr|StsIddl}|jd|jantj}d}d}ttdd}nXd|kr|St sddl}|jd |ja nt j}d }d }tj }d}x|||}|sPn|j d\}}|j d } | j|rB| j|rB| d d } ny<|dkrstjtj tj| } n || } Wntk r|}YqX||d} |d|| }t|}|| 7}q|S(uZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.s$iNs\$(\w+|\{[^}]*\})s{s}uenvironbu$u\$(\w+|\{[^}]*\})u{u}ii(u isinstanceubytesu _varprogbureucompileuASCIIusearchugetattruosuNoneu_varproguenvironuspanugroupu startswithuendswithufsencodeufsdecodeuKeyErrorulen( upathureusearchustartuenduenvironuiumujunameuvalueutail((u./opt/alt/python33/lib64/python3.3/posixpath.pyu expandvars"sN        "    c Cs^t|tr*d}d}d}d}nd}d}d}d}||krR|S|j|}|r|j|d r|j|d  rd }n|j|}g}xy|D]q}|||fkrqn||ks| r| s|r|d |kr|j|q|r|jqqW|}|j|}|rT|||}n|p]|S( u0Normalize path, eliminating double slashes, etc.s/ss.s..u/uu.u..iiii(u isinstanceubytesu startswithusplituappendupopujoin( upathusepuemptyudotudotdotuinitial_slashesucompsu new_compsucomp((u./opt/alt/python33/lib64/python3.3/posixpath.pyunormpathVs<  '  cCsRt|sHt|tr*tj}n tj}t||}nt|S(uReturn an absolute path.(uisabsu isinstanceubytesuosugetcwdbugetcwdujoinunormpath(upathucwd((u./opt/alt/python33/lib64/python3.3/posixpath.pyuabspath{s   cCs,t|dd|i\}}t|S(ulReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Ni(u _joinrealpathuabspath(ufilenameupathuok((u./opt/alt/python33/lib64/python3.3/posixpath.pyurealpaths"c Cst|tr$d}d}d}nd}d}d}t|r[|dd}|}nx?|r|j|\}}}| s^||krq^n||kr|rt|\}}||krt|||}qq^|}q^nt||}t|s|}q^n||krK||}|dk r8q^nt||dfSd||s urelpath..cSsg|]}|r|qS(((u.0ux((u./opt/alt/python33/lib64/python3.3/posixpath.pyu s N( u ValueErroru isinstanceubytesuNoneuabspathusplitulenu commonprefixujoin( upathustartucurdirusepupardiru start_listu path_listuiurel_list((u./opt/alt/python33/lib64/python3.3/posixpath.pyurelpaths$   ""%(*u__doc__uosusysustatu genericpathu__all__ucurdirupardiruextsepusepupathsepudefpathuNoneualtsepudevnullu_get_sepunormcaseuisabsujoinusplitusplitextu _splitextu splitdriveubasenameudirnameuislinkulexistsusamefileu sameopenfileusamestatuismountu expanduseru_varprogu _varprogbu expandvarsunormpathuabspathurealpathu _joinrealpathuplatformusupports_unicode_filenamesurelpath(((u./opt/alt/python33/lib64/python3.3/posixpath.pyu s\           " * 4 %   3