[O&@sNdZddlZddlZddlZddlZddlTdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)g&Zd*Zd+Zd*Zd,Z d-Z d.Z d/Z d0ej krd1Z nd2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Zd?d@ZdAdZdBdZdCdZdDdZdEdZdFdZdGd Zejje_dHd ZdId ZdJdZ dKdZ!yddLl"m#Z#Wne$k rdZ#YnXdMdZ%dNdZ&dOdZ'dPdZ(yddQl"m)Z)Wne$k rzdRdZ*Yn XdSdZ*e*Z+e,edToej-dUdVkZ.edWd&Z/y9ej-ddVd]krddYl"m0Z0ne$Wn$e1e$fk r dZd[Z0YnXydd\l"m2Z3Wne$k rIYnXdS)^zCommon pathname manipulations, WindowsNT/95 version. Instead of importing this module directly, import os and refer to this module as os.path. N)*normcaseisabsjoin splitdrivesplitsplitextbasenamedirname commonprefixgetsizegetmtimegetatimegetctimeislinkexistslexistsisdirisfileismount expanduser expandvarsnormpathabspathsplitunccurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpathsamefile sameopenfilesamestat.z..\;/z.;C:\binZcez\WindowsZnulcCst|trdSdSdS)N) isinstancebytes)pathr2/usr/lib/python3.4/ntpath.py _get_empty#sr4cCst|trdSdSdS)Ns\r*)r/r0)r1r2r2r3_get_sep)sr5cCst|trdSdSdS)N/r,)r/r0)r1r2r2r3 _get_altsep/sr7cCst|trdSdSdS)Ns\/z\/)r/r0)r1r2r2r3 _get_bothseps5sr8cCst|trdSdSdS)N.r))r/r0)r1r2r2r3_get_dot;sr:cCst|trdSdSdS)N::)r/r0)r1r2r2r3 _get_colonAsr=cCst|trdSdSdS)N\\.\\\?\\\.\\\?\)r>r?)r@rA)r/r0)r1r2r2r3 _get_specialGsrBcCsUt|ttfs3tdj|jjn|jt|t |j S)zaNormalize case of pathname. Makes all characters lowercase and all slashes into backslashes.z2normcase() argument must be str or bytes, not '{}') r/r0str TypeErrorformat __class____name__replacer7r5lower)sr2r2r3rQs cCs<t|d}t|dko;|ddt|kS)zTest whether a path is absoluterN)rlenr8)rJr2r2r3rasc GsIt|}t|}t|}t|\}}x|D]}t|\}} | r| d|kr|sx| r|}n| }q=nE|r||kr|j|jkr|}| }q=n|}n|r|d|kr||}n|| }q=W|rA|d|krA|rA|dd|krA|||S||S)NrrKrM)r5r8r=rrI) r1ZpathsrsepsZcolonZ result_driveZ result_pathpZp_driveZp_pathr2r2r3rhs0         cCsJt|}t|dkr@t|}|jt||}|dd|dkr|dd|kr|j|d}|dkr||fS|j||d}||dkr||fS|dkrt|}n|d|||dfS|ddt|kr@|dd|ddfSn||fS)aSplit 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. rKrNrMrM)r4rLr5rHr7findr=)rOemptyrZnormpindexZindex2r2r2r3rs"  0    !cCsaddl}|jdtdt|\}}t|dkrW|dd|fS||fS)aDeprecated since Python 3.1. Please use splitdrive() instead; it now handles UNC paths. 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. rNzs0 %   "cCsut|trtd|kr7td|kr7|Sddl}t|j|jdd}d}d}d }d }ttd d}n]d|krd|kr|Sddl}|j|jd}d }d}d }d}tj}|dd}d} t |} xb| | krp|| | d} | |kr|| dd}t |} y/|j | } || |d| d7}Wqct k r||7}| d} YqcXn| |kr|| d| d|kr|| 7}| d7} qc|| dd}t |} y|j |} Wn*t k rV|||7}| d} YqcX|d| } y<|dkrtj tjtj | } n || } Wn tk r|| |} YnX|| 7}n| |krY|| d| d|kr|| 7}| d7} qc|| d| d|kro|| dd}t |} y4t|trv|j d} n|j d} WnJt k rt|tr|d|7}n|d|7}| d} YqVX|d| } y<|dkrtj tjtj | } n || } Wn@tk rat|trOd| d} nd| d} YnX|| 7}qc|dd} | d7} || | d} x>| r| |kr| | 7} | d7} || | d} qWy<|dkrtj tjtj | } n || } Wntk r8|| } YnX|| 7}| rc| d8} qcn || 7}| d7} qW|S)zfExpand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.$%rNz_-asciis'%{$environb'{rKrP}}s${z${)r/r0ordstringZ ascii_lettersZdigitsgetattrr_rorLrT ValueErrorfsencodefsdecoderp)r1rZvarcharsZquoteZpercentZbraceZdollarroZresrTZpathlencZvarvaluer2r2r3ros$               "        "      "   cCst|}t|d}t|}|j|r;|S|jt||}t|\}}|j|r||7}|j|}n|j|}d}x|t |kr||| s||t|kr||=q|||kro|dkr7||d|kr7||d|d=|d8}qy|dkrb|j t|rb||=qy|d7}q|d7}qW| r| r|j t|n||j |S)z0Normalize path, eliminating double slashes, etc.rPrrK) r5r:rBrnrHr7rlstriprrLendswithappendr)r1rdotdotZspecial_prefixesprefixcompsrZr2r2r3rs4   !   !  )_getfullpathnamecCsRt|sHt|tr*tj}n tj}t||}nt|S)z&Return the absolute version of a path.)rr/r0r_getcwdbgetcwdrr)r1cwdr2r2r3rs   c Csb|r.yt|}WqXtk r*YqXXn*t|trLtj}n tj}t|S)z&Return the absolute version of a path.)rrar/r0r_rrr)r1r2r2r3rs  getwindowsversionrQrPcCst|}|tkr't|}n|s<tdntt|}tt|}t|\}}t|\}}t|t|krdj||} t| ndd|j |D} dd|j |D} d} xCt | | D]2\} }t| t|kr3Pn| d7} q Wt |t rYd}nd }|gt | | | | d }|st|St|S) z#Return a relative version of a pathzno path specifiedz,path is on mount '{0}', start on mount '{1}'cSsg|]}|r|qSr2r2).0xr2r2r3 Es zrelpath..cSsg|]}|r|qSr2r2)rrr2r2r3rFs rrKs..z..N)r5rr:rrrrrrErzipr/r0rLr)r1startrZ start_absZpath_absZ start_driveZ start_restZ path_driveZ path_resterror start_list path_listrZZe1Ze2rrel_listr2r2r3r%2s6    % )_getfinalpathnamecCstt|S)N)rr)fr2r2r3resr)_isdir)rr)4__doc__r_rrrcr]__all__rrr!rrr rbuiltin_module_namesr"r4r5r7r8r:r=rBrrrrrrrr^r r rrntrg ImportErrorrrrrrrr#hasattrrr$r%rrbrrr2r2r2r3s               # -          1 w )  '