zfc&@sdZddlZddlZddlZddlZddlZddlTddlmZddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*g&Zd+Zd,Z d+Z d-Z d.Z d/Z dZd0Zd1Zd2Zd3Zd4Zd5Zejje_d6Zd7Zd8Zd9Zd:Zd;Zd<Zd=Zd>Zd?Z d@Z!da"da#dAZ$dBZ%dCZ&dDZ'dEZ(ej)dFkZ*edGZ+dS(HsCommon 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(t*(t_unicodetnormcasetisabstjoint splitdrivetsplittsplitexttbasenametdirnamet commonprefixtgetsizetgetmtimetgetatimetgetctimetislinktexiststlexiststisdirtisfiletismounttwalkt expandusert expandvarstnormpathtabspathtsamefilet sameopenfiletsamestattcurdirtpardirtseptpathseptdefpathtaltseptextseptdevnulltrealpathtsupports_unicode_filenamestrelpatht.s..t/t:s:/bin:/usr/bins /dev/nullcCs|S(s6Normalize case of pathname. Has no effect under Posix((ts((s!/usr/lib64/python2.7/posixpath.pyR,scCs |jdS(sTest whether a path is absoluteR)(t startswith(R+((s!/usr/lib64/python2.7/posixpath.pyR4scGsi|}x\|D]T}|jdr+|}q |dksF|jdrS||7}q |d|7}q W|S(sJoin 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.R)t(R,tendswith(tatptpathtb((s!/usr/lib64/python2.7/posixpath.pyR=s   cCs`|jdd}|| ||}}|rV|dt|krV|jd}n||fS(sSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.R)i(trfindtlentrstrip(R0titheadttail((s!/usr/lib64/python2.7/posixpath.pyRRs cCstj|tttS(N(t genericpatht _splitextRR"R#(R0((s!/usr/lib64/python2.7/posixpath.pyRascCs d|fS(sJSplit a pathname into drive and path. On Posix, drive is always empty.R-((R0((s!/usr/lib64/python2.7/posixpath.pyRhscCs|jdd}||S(s)Returns the final component of a pathnameR)i(R3(R0R6((s!/usr/lib64/python2.7/posixpath.pyRpscCsO|jdd}|| }|rK|dt|krK|jd}n|S(s-Returns the directory component of a pathnameR)i(R3R4R5(R0R6R7((s!/usr/lib64/python2.7/posixpath.pyR xs  cCsAytj|}Wntjtfk r0tSXtj|jS(s&Test whether a path is a symbolic link(tostlstatterrortAttributeErrortFalsetstattS_ISLNKtst_mode(R1tst((s!/usr/lib64/python2.7/posixpath.pyRs cCs-ytj|Wntjk r(tSXtS(sCTest whether a path exists. Returns True for broken symbolic links(R;R<R=R?tTrue(R1((s!/usr/lib64/python2.7/posixpath.pyRs cCs+tj|}tj|}t||S(s9Test whether two pathnames reference the same actual file(R;R@R(tf1tf2ts1ts2((s!/usr/lib64/python2.7/posixpath.pyRscCs+tj|}tj|}t||S(s:Test whether two open file objects reference the same file(R;tfstatR(tfp1tfp2RGRH((s!/usr/lib64/python2.7/posixpath.pyRscCs"|j|jko!|j|jkS(s5Test whether two stat buffers reference the same file(tst_inotst_dev(RGRH((s!/usr/lib64/python2.7/posixpath.pyRscCst|rtSy1tj|}tjtt|d}Wntjk rXtSX|j}|j}||kr{tS|j }|j }||krtStS(s$Test whether a path is a mount points..( RR?R;R<R%RR=RMRDRL(R1RGRHtdev1tdev2tino1tino2((s!/usr/lib64/python2.7/posixpath.pyRs  "      cCstjdddytj|}Wntjk r=dSX||||xo|D]g}t||}ytj|}Wntjk rqUnXtj|j rUt |||qUqUWdS(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.s4In 3.x, os.path.walk is removed in favor of os.walk.t stackleveliN( twarningstwarnpy3kR;tlistdirR=RR<R@tS_ISDIRRBR(ttoptfunctargtnamestnameRC((s!/usr/lib64/python2.7/posixpath.pyRs  cCs|jds|S|jdd}|dkr@t|}n|dkrdtjkrddl}y|jtjj}Wqt k r|SXqtjd}nDddl}y|j |d|!}Wnt k r|SX|j}|j d}|||pdS(sOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.t~R)iitHOMEiN( R,tfindR4R;tenvirontpwdtgetpwuidtgetuidtpw_dirtKeyErrortgetpwnamR5(R1R6R`tuserhometpwent((s!/usr/lib64/python2.7/posixpath.pyRs*       c Csd|kr|St|tr^tsIddl}|jd|jant}tj}n0tsddl}|jdant}d}d}xt r|j ||}|sPn|j d\}}|j d}|jdr |jd r |dd!}n|r#|j|}n|tjkr||}tj|} |ra| j|} n|| | }t|}||7}q|}qW|S( sZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.t$iNu\$(\w+|\{[^}]*\})s\$(\w+|\{[^}]*\})iit{t}(t isinstanceRt _uvarprogtretcompiletUNICODEtsystgetfilesystemencodingt_varprogtNoneRDtsearchtspantgroupR,R.tencodeR;R_tdecodeR4( R1RmtvarprogtencodingR6tmtjR[R8tvalue((s!/usr/lib64/python2.7/posixpath.pyR"sD         cCs/t|trd nd \}}|dkr1|S|jd}|rn|jdrn|jd rnd}n|jd}g}xs|D]k}|d krqn|d ks| r| s|r|d d kr|j|q|r|jqqW|}|j|}|r%|||}n|p.|S(s0Normalize path, eliminating double slashes, etc.u/u.R)R(R-s//s///is..i(u/u.(R)R((R-R((RkRR,RtappendtpopR(R1tslashtdottinitial_slashestcompst new_compstcomp((s!/usr/lib64/python2.7/posixpath.pyRPs,!    cCsRt|sHt|tr*tj}n tj}t||}nt|S(sReturn an absolute path.(RRkRR;tgetcwdutgetcwdRR(R1tcwd((s!/usr/lib64/python2.7/posixpath.pyRms   cCs"td|i\}}t|S(slReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.R-(t _joinrealpathR(tfilenameR1tok((s!/usr/lib64/python2.7/posixpath.pyR%{scCskt|r|d}t}nx?|r`|jt\}}}| s"|tkrYq"n|tkr|rt|\}}|tkrt|tt}qq"t}q"nt||}t|s|}q"n||kr||}|dk rq"nt||t fSd|| s`               ( $ .    *