kWc$@s`dZddlZddlZddlZddlZddlZddlTdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'g$Zd(Zd)Zd(Z d*Z d+Z d,Z d-Z d.ejkrd/Z nd0ejkrd,Z nd1Zd2Zd3Zd4Zd5Zd6Zd7Zd8Zejje_d9Zd:Zd;ZeZd<Zd=Zd>Zd?Z d@Z!yddAl"m#Z#Wne$k rdBZ%n XdCZ%e%Z&e'edDoej(dEdFkZ)dGZ*edHZ+yddIl"m,Z-Wne$k r[nXdS(JsCommon pathname manipulations, WindowsNT/95 version. Instead of importing this module directly, import os and refer to this module as os.path. iN(t*tnormcasetisabstjoint splitdrivetsplittsplitexttbasenametdirnamet commonprefixtgetsizetgetmtimetgetatimetgetctimetislinktexiststlexiststisdirtisfiletismounttwalkt expandusert expandvarstnormpathtabspathtsplitunctcurdirtpardirtseptpathseptdefpathtaltseptextseptdevnulltrealpathtsupports_unicode_filenamestrelpatht.s..s\t;t/s.;C:\bintces\Windowstos2tnulcCs|jddjS(saNormalize case of pathname. Makes all characters lowercase and all slashes into backslashes.R's\(treplacetlower(ts((s/usr/lib/python2.7/ntpath.pyR*scCs*t|d}|dko)|d dkS(sTest whether a path is absoluteits/\(R(R-((s/usr/lib/python2.7/ntpath.pyR7scGst|\}}x|D]}t|\}}|ri|ddkri|sT| r]|}n|}qnE|r||kr|j|jkr|}|}qn|}n|r|ddkr|d}n||}qW|r|ddkr|r|ddkr|t|S||S(s>Join two or more pathname components, inserting "\" as needed.is\/is\t:(RR,R(tpathtpathst result_drivet result_pathtptp_drivetp_path((s/usr/lib/python2.7/ntpath.pyR>s*      cCst|dkr|jtt}|dd!tdkr|dd!tkr|jtd}|dkrvd|fS|jt|d}||dkrd|fS|dkrt|}n|| ||fS|ddkr|d |dfSnd|fS(sSplit a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive letter, drive_or_unc will contain everything up to and including the colon. e.g. splitdrive("c:/dir") returns ("c:", "/dir") If the path contained a UNC path, the drive_or_unc will contain the host name and share up to but not including the fourth directory separator character. e.g. splitdrive("//host/computer/dir") returns ("//host/computer", "/dir") Paths cannot contain both a drive letter and a UNC path. iiiiiR.R/(tlenR+RRtfind(R4tnormptindextindex2((s/usr/lib/python2.7/ntpath.pyR_s*    cCs|dd!dkrd|fS|dd!}|dksB|dkr|jdd }|jd d}|dkr|d|fS|jd |d}||dkrd|fS|d krt|}n|| ||fSd|fS( s@Split a pathname into UNC mount point and relative path specifiers. Return a 2-tuple (unc, rest); either part may be empty. If unc is not empty, it has the form '//host/mount' (or similar using backslashes). unc+rest is always the input path. Paths containing drive letters never have an UNC part. iiR/R.is//s\\s\R'i(R+R8R7(R4tfirstTwoR9R:R;((s/usr/lib/python2.7/ntpath.pyRs      cCst|\}}t|}x(|rH||ddkrH|d}q!W|| ||}}|}x$|r|ddkr|d }qgW|p|}|||fS(s~Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.is/\i(RR7(R4tdtitheadttailthead2((s/usr/lib/python2.7/ntpath.pyRs  cCstj|tttS(N(t genericpatht _splitextRRR (R4((s/usr/lib/python2.7/ntpath.pyRscCst|dS(s)Returns the final component of a pathnamei(R(R4((s/usr/lib/python2.7/ntpath.pyRscCst|dS(s-Returns the directory component of a pathnamei(R(R4((s/usr/lib/python2.7/ntpath.pyRscCstS(sNTest for symbolic link. On WindowsNT/95 and OS/2 always returns false (tFalse(R0((s/usr/lib/python2.7/ntpath.pyRscCsRt|\}}|r"|dkSt|d}t|dkoQ|ddkS(s?Test whether a path is a mount point (defined as root of drive)R.R's\iis/\(R.R's\(RRR7(R0tunctrestR4((s/usr/lib/python2.7/ntpath.pyRs  cCstjdddytj|}Wntjk r=dSX||||x<|D]4}t||}t|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(twarningstwarnpy3ktostlistdirterrorRRR(ttoptfunctargtnamestname((s/usr/lib/python2.7/ntpath.pyRs   cCs|d dkr|Sdt|}}x*||krS||dkrS|d}q*Wdtjkrstjd}nsdtjkrtjd}nTdtjkr|Sytjd}Wntk rd}nXt|tjd}|dkrtt||d|!}n|||S( sLExpand ~ and ~user constructs. If user or $HOME is unknown, do nothing.it~s/\tHOMEt USERPROFILEtHOMEPATHt HOMEDRIVER.(R7RJtenvirontKeyErrorRR(R0R>tntuserhometdrive((s/usr/lib/python2.7/ntpath.pyRs&   c sd|krd|kr|Sddl}|j|jd}t|tritjfd}n d}d}d }t|}x6||kr||}|d kr||d }t|}y)|jd }|d ||d  }Wqt k r||}|d }qXn|dkr||d |d !dkr[||}|d }q||d }t|}y|jd}Wn)t k r|d|}|d }qX|| }y|||}Wqt k r|d|d}qXn|dkr||d |d !dkr9||}|d }q||d |d !d kr||d }t|}yW|jd}|| }y|||}Wn#t k r|d|d}nXWqt k r|d|}|d }qXqd}|d }|||d !}xA|dkrX||krX||}|d }|||d !}qWy|||}Wnt k r|d|}nX|dkr|d }qn ||}|d }qW|S(sfExpand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.t$t%iNs_-cstj|jjS(N(RJRWtencodetdecode(tvar(tencoding(s/usr/lib/python2.7/ntpath.pytgetenvPscSs tj|S(N(RJRW(R`((s/usr/lib/python2.7/ntpath.pyRbSsR.is'iit{t}s${( tstringt ascii_letterstdigitst isinstancetunicodetsystgetfilesystemencodingR7R:t ValueErrorRX( R0RetvarcharsRbtresR:tpathlentcR`((Ras/usr/lib/python2.7/ntpath.pyRFs                             cCst|trd nd \}}|jdr4|S|jdd}t|\}}|dkrxV|d dkr||}|d }qgWn+|jdr||}|jd}n|jd}d }x|t|kr||dkr||=q||d kr|d krP||d d krP||d |d 5|d 8}q|d kru|jdru||=q|d 7}q|d 7}qW| r| r|j |n||j |S(s0Normalize path, eliminating double slashes, etc.u\u.s\R%s\\.\s\\?\R'R.iis..(u\u.(s\R%(s\\.\s\\?\(R%R.( RhRit startswithR+RtlstripRR7tendswithtappendR(R0t backslashtdottprefixtcompsR>((s/usr/lib/python2.7/ntpath.pyRs8!        (t_getfullpathnamecCsRt|sHt|tr*tj}n tj}t||}nt|S(s&Return the absolute version of a path.(RRhRiRJtgetcwdutgetcwdRR(R0tcwd((s/usr/lib/python2.7/ntpath.pyRs   cCsa|r-yt|}WqWtk r)qWXn*t|trKtj}n tj}t|S(s&Return the absolute version of a path.(Ryt WindowsErrorRhRiRJRzR{R(R0((s/usr/lib/python2.7/ntpath.pyRs  tgetwindowsversioniicCsztt|}t|\}}t|}|sKt|\}}n||g|jtD]}|ra|^qafS(N(RRRtboolRRR(R0tabsRwRFtis_unctx((s/usr/lib/python2.7/ntpath.pyt_abspath_splits  c Cs1|stdnt|\}}}t|\}}}||Arbtd||fn|j|jkr|rtd||fqtd||fnd}xCt||D]2\} } | j| jkrPn|d7}qWtgt||||} | s'tSt| S(s#Return a relative version of a pathsno path specifieds,Cannot mix UNC and non-UNC paths (%s and %s)s,path is on UNC root %s, start on UNC root %ss&path is on drive %s, start on drive %sii(RlRR,tzipRR7RR( R0tstartt start_is_unct start_prefixt start_listt path_is_unct path_prefixt path_listR>te1te2trel_list((s/usr/lib/python2.7/ntpath.pyR$s, (t_isdir(.t__doc__RJRjtstatRBRHt__all__RRR RRRRtbuiltin_module_namesR!RRRRRRRRCRRRRRRRRRRtntRyt ImportErrorRR"thasattrR~R#RR$RR(((s/usr/lib/python2.7/ntpath.pytsn          ! * $       $ * X 5