Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/posixpath.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c&@sdZddlZddlZddlZddlZddlZddlTy
eZWn'ek
rde	fd��YZnXdddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+g&Z
d,Zd-Zd,Z
d.Zd/Zd0ZdZd1Zd2�Zd3�Zd4�Zd5�Zd6�Zejje_d7�Zd8�Zd9�Zd:�Zd;�Zd<�Zd=�Z d>�Z!d?�Z"d@�Z#dA�Z$da%da&dB�Z'dC�Z(dD�Z)dE�Z*dF�Z+ej,dGkZ-edH�Z.dS(Is�Common 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.
i�N(t*t_unicodecBseZRS((t__name__t
__module__(((s/sys/lib/python2.7/posixpath.pyRstnormcasetisabstjoint
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/sys/lib/python2.7/posixpath.pyR3scCs
|jd�S(sTest whether a path is absoluteR+(t
startswith(R-((s/sys/lib/python2.7/posixpath.pyR;scGsi|}x\|D]T}|jd�r+|}q
|dksF|jd�rS||7}q
|d|7}q
W|S(s�Join 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/sys/lib/python2.7/posixpath.pyRDs
	
cCs`|jd�d}|| ||}}|rV|dt|�krV|jd�}n||fS(s�Split a pathname.  Returns tuple "(head, tail)" where "tail" is
    everything after the final slash.  Either part may be empty.R+i(trfindtlentrstrip(R2titheadttail((s/sys/lib/python2.7/posixpath.pyRYs
cCstj|ttt�S(N(tgenericpatht	_splitextR!R$R%(R2((s/sys/lib/python2.7/posixpath.pyR	hscCs
d|fS(sJSplit a pathname into drive and path. On Posix, drive is always
    empty.R/((R2((s/sys/lib/python2.7/posixpath.pyRoscCs|jd�d}||S(s)Returns the final component of a pathnameR+i(R5(R2R8((s/sys/lib/python2.7/posixpath.pyR
wscCsO|jd�d}|| }|rK|dt|�krK|jd�}n|S(s-Returns the directory component of a pathnameR+i(R5R6R7(R2R8R9((s/sys/lib/python2.7/posixpath.pyRs

cCsAytj|�}Wntjtfk
r0tSXtj|j�S(s&Test whether a path is a symbolic link(tostlstatterrortAttributeErrortFalsetstattS_ISLNKtst_mode(R3tst((s/sys/lib/python2.7/posixpath.pyR�s
cCs-ytj|�Wntjk
r(tSXtS(sCTest whether a path exists.  Returns True for broken symbolic links(R=R>R?RAtTrue(R3((s/sys/lib/python2.7/posixpath.pyR�s
cCs+tj|�}tj|�}t||�S(s9Test whether two pathnames reference the same actual file(R=RBR(tf1tf2ts1ts2((s/sys/lib/python2.7/posixpath.pyR�scCs+tj|�}tj|�}t||�S(s:Test whether two open file objects reference the same file(R=tfstatR(tfp1tfp2RIRJ((s/sys/lib/python2.7/posixpath.pyR�scCs"|j|jko!|j|jkS(s5Test whether two stat buffers reference the same file(tst_inotst_dev(RIRJ((s/sys/lib/python2.7/posixpath.pyR�scCs�t|�rtSy+tj|�}tjt|d��}Wntjk
rRtSX|j}|j}||krutS|j}|j}||kr�tStS(s$Test whether a path is a mount points..(	RRAR=R>RR?RORFRN(R3RIRJtdev1tdev2tino1tino2((s/sys/lib/python2.7/posixpath.pyR�s 				cCs�tjddd�ytj|�}Wntjk
r=dSX||||�xo|D]g}t||�}ytj|�}Wntjk
r�qUnXtj|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>RBtS_ISDIRRDR(ttoptfunctargtnamestnameRE((s/sys/lib/python2.7/posixpath.pyR�s
cCs�|jd�s|S|jdd�}|dkr@t|�}n|dkr�dtjkr�ddl}|jtj��j}q�tjd}nDddl}y|j	|d|!�}Wnt
k
r�|SX|j}|jd�}|||p�S(sOExpand ~ and ~user constructions.  If user or $HOME is unknown,
    do nothing.t~R+iitHOMEi�N(R.tfindR6R=tenvirontpwdtgetpwuidtgetuidtpw_dirtgetpwnamtKeyErrorR7(R3R8Rbtuserhometpwent((s/sys/lib/python2.7/posixpath.pyRs$
	c
Cs�d|kr|St|t�rXtsCddl}|jd�ant}tj�}n<ts�ddl}|jtd�|j�ant}d}d}x�r�|j||�}|s�Pn|jd�\}}|j
d�}|jd�r|jd�r|dd!}n|r)|j|�}n|tjkr�||}tj|}	|rg|	j|�}	n|| |	}t|�}||7}q�|}q�W|S(	sZExpand shell variables of form $var and ${var}.  Unknown variables
    are left unchanged.t$i�Ns\$(\w+|\{[^}]*\})iit{t}(t
isinstanceRt_varprogtretcompiletsystgetfilesystemencodingt	_uvarprogtUNICODEtNoneRFtsearchtspantgroupR.R0tencodeR=RatdecodeR6(
R3RotvarprogtencodingR8tmtjR]R:tvalue((s/sys/lib/python2.7/posixpath.pyR"sD	



cCs/t|t�rdnd\}}|dkr1|S|jd�}|rn|jd�rn|jd�rnd}n|jd�}g}xs|D]k}|d
kr�q�n|d	ks�|r�|s�|r�d
d	kr�j|�q�|r�|j�q�q�W|}|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*(RmRR.RtappendtpopR(R3tslashtdottinitial_slashestcompst	new_compstcomp((s/sys/lib/python2.7/posixpath.pyRPs,!	
cCsRt|�sHt|t�r*tj�}ntj�}t||�}nt|�S(sReturn an absolute path.(RRmRR=tgetcwdutgetcwdRR(R3tcwd((s/sys/lib/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(tfilenameR3tok((s/sys/lib/python2.7/posixpath.pyR'{scCskt|�r|d}t}nx?|r`|jt�\}}}|s"|tkrYq"n|tkr�|r�t|�\}}|tkr�t|tt�}q�q"t}q"nt||�}t|�s�|}q"n||kr||}|dk	r�nt||�t	fSd||<t
|tj|�|�\}}|sSt||�t	fS|||<q"W|t
fS(Ni(RR!t	partitionRR RRRRuRAR�R=treadlinkRF(R3tresttseenR]t_tnewpathR�((s/sys/lib/python2.7/posixpath.pyR��s:
		

!tdarwincCs�|std��ngt|�jt�D]}|r+|^q+}gt|�jt�D]}|rY|^qY}tt||g��}tgt|�|||}|s�tSt|�S(s#Return a relative version of a pathsno path specified(	t
ValueErrorRRR!R6RR RR(R3tstarttxt
start_listt	path_listR8trel_list((s/sys/lib/python2.7/posixpath.pyR)�s..(/t__doc__R=RqRBR;RUtunicodeRt	NameErrortobjectt__all__RR R%R!R"R#RuR$R&RRRRR	R<RR
RRRRRRRRRRnRsRRRR'R�tplatformR(R)(((s/sys/lib/python2.7/posixpath.pyt<module>sf


											
		
	
				(		.				*

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].