Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/posixpath.pyc

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


�
��c'@s�dZddkZddkZddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'g%Zd(Zd)Zd(Zd*Zd+Zd,Z	dZd-Zd.�Z
d/�Zd0�Zd1�Zd2�Zd3�Zd4�Zd5�Zd6�Zd7�Zd8�Zd9�Zd:�Zd;�Zd<�Zd=�Zd>�Zd?�Zd@�ZdA�Z dB�Z!dC�Z"dD�Z#dE�Z$da%dF�Z&dG�Z'dH�Z(dI�Z)dJ�Z*e+Z,dS(Ks�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�Ntnormcasetisabstjoint
splitdrivetsplittsplitexttbasenametdirnametcommonprefixtgetsizetgetmtimetgetatimetgetctimetislinktexiststlexiststisdirtisfiletismounttwalkt
expandusert
expandvarstnormpathtabspathtsamefiletsameopenfiletsamestattcurdirtpardirtseptpathseptdefpathtaltseptextseptdevnulltrealpathtsupports_unicode_filenamest.s..t/t:s:/bin:/usr/bins	/dev/nullcCs|S(s6Normalize case of pathname.  Has no effect under Posix((ts((s/sys/lib/python/posixpath.pyR'scCs
|id�S(sTest whether a path is absoluteR&(t
startswith(R(((s/sys/lib/python/posixpath.pyR/scGsn|}xa|D]Y}|id�o
|}q
|djp|id�o||7}q
|d|7}q
W|S(s=Join two or more pathname components, inserting '/' as neededR&t(R)tendswith(tatptpathtb((s/sys/lib/python/posixpath.pyR8s
cCsc|id�d}|| ||}}|o*|dt|�jo|id�}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(R-titheadttail((s/sys/lib/python/posixpath.pyRJs
cCsI|id�}||id�jo|dfSn|| ||fSdS(s�Split the extension from a pathname.  Extension is everything from the
    last dot to the end.  Returns "(root, ext)", either part may be empty.R%R&R*N(R0(R-R3((s/sys/lib/python/posixpath.pyRYscCs
d|fS(sJSplit a pathname into drive and path. On Posix, drive is always
    empty.R*((R-((s/sys/lib/python/posixpath.pyRfscCst|�dS(s)Returns the final component of a pathnamei(R(R-((s/sys/lib/python/posixpath.pyRnscCst|�dS(s-Returns the directory component of a pathnamei(R(R-((s/sys/lib/python/posixpath.pyRuscCs�|pdSnt|�}t|�}tt|�t|��}x5t|�D]'}||||jo|| SqOqOW|| S(sGGiven a list of pathnames, returns the longest common leading componentR*(tmintmaxR1txrange(tmts1ts2tnR3((s/sys/lib/python/posixpath.pyR|s
cCsti|�iS(s1Return the size of a file, reported by os.stat().(toststattst_size(tfilename((s/sys/lib/python/posixpath.pyR	�scCsti|�iS(sCReturn the last modification time of a file, reported by os.stat().(R=R>tst_mtime(R@((s/sys/lib/python/posixpath.pyR
�scCsti|�iS(s=Return the last access time of a file, reported by os.stat().(R=R>tst_atime(R@((s/sys/lib/python/posixpath.pyR�scCsti|�iS(sAReturn the metadata change time of a file, reported by os.stat().(R=R>tst_ctime(R@((s/sys/lib/python/posixpath.pyR�scCsFyti|�}Wn titfj
otSnXti|i�S(s&Test whether a path is a symbolic link(R=tlstatterrortAttributeErrortFalseR>tS_ISLNKtst_mode(R.tst((s/sys/lib/python/posixpath.pyR
�s
	cCs4yti|�}Wntij
otSnXtS(sDTest whether a path exists.  Returns False for broken symbolic links(R=R>RERGtTrue(R.RJ((s/sys/lib/python/posixpath.pyR�s
	cCs4yti|�}Wntij
otSnXtS(sCTest whether a path exists.  Returns True for broken symbolic links(R=RDRERGRK(R.RJ((s/sys/lib/python/posixpath.pyR�s
	cCs@yti|�}Wntij
otSnXti|i�S(s"Test whether a path is a directory(R=R>RERGtS_ISDIRRI(R.RJ((s/sys/lib/python/posixpath.pyR�s
	cCs@yti|�}Wntij
otSnXti|i�S(s%Test whether a path is a regular file(R=R>RERGtS_ISREGRI(R.RJ((s/sys/lib/python/posixpath.pyR�s
	cCs+ti|�}ti|�}t||�S(s9Test whether two pathnames reference the same actual file(R=R>R(tf1tf2R:R;((s/sys/lib/python/posixpath.pyR�scCs+ti|�}ti|�}t||�S(s:Test whether two open file objects reference the same file(R=tfstatR(tfp1tfp2R:R;((s/sys/lib/python/posixpath.pyR�scCs#|i|ijo|i|ijS(s5Test whether two stat buffers reference the same file(tst_inotst_dev(R:R;((s/sys/lib/python/posixpath.pyR�scCs�y+ti|�}tit|d��}Wntij
otSnX|i}|i}||jotSn|i}|i}||jotSntS(s$Test whether a path is a mount points..(R=R>RRERGRTRKRS(R.R:R;tdev1tdev2tino1tino2((s/sys/lib/python/posixpath.pyR�s			
		
cCs�yti|�}Wntij
odSnX||||�xs|D]k}t||�}yti|�}Wntij
o
qGnXti|i�ot|||�qGqGWdS(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.N(	R=tlistdirRERRDR>RLRIR(ttoptfunctargtnamestnameRJ((s/sys/lib/python/posixpath.pyRs	cCs|id�p|Sn|idd�}|djot|�}n|djoIdtijo(ddk}|iti��i}q�tid}nJddk}y|i	|d|!�}Wnt
j
o|SnX|i}|id�}|||S(sOExpand ~ and ~user constructions.  If user or $HOME is unknown,
    do nothing.t~R&iitHOMEi�N(R)tfindR1R=tenvirontpwdtgetpwuidtgetuidtpw_dirtgetpwnamtKeyErrorR2(R.R3Rctuserhometpwent((s/sys/lib/python/posixpath.pyR6s$

		cCsd|jo|Sntpddk}|id�and}x�to�ti||�}|pPn|id�\}}|id�}|id�o!|id�o|dd!}n|t	i
jo9||}|| t	i
|}t|�}||7}qD|}qDW|S(	sZExpand shell variables of form $var and ${var}.  Unknown variables
    are left unchanged.t$i�Ns\$(\w+|\{[^}]*\})iit{t}(t_varprogtretcompileRKtsearchtspantgroupR)R+R=RbR1(R.RoR3R9tjR^R5((s/sys/lib/python/posixpath.pyRUs*

 
cCs$|djodSn|id�}|o+|id�o|id�o
d}n|id�}g}x}|D]u}|d	joqrn|djp(|o|p|o"|ddjo|i|�qr|o|i�qrqrW|}di|�}|od||}n|pdS(
s0Normalize path, eliminating double slashes, etc.R*R%R&s//s///is..i�(R*R%(R)RtappendtpopR(R.tinitial_slashestcompst	new_compstcomp((s/sys/lib/python/posixpath.pyRus,
!

cCs0t|�ptti�|�}nt|�S(sReturn an absolute path.(RRR=tgetcwdR(R.((s/sys/lib/python/posixpath.pyR�s
cCs�t|�odg|id�d}ndg|id�}x�tdt|�d�D]�}t|d|!�}t|�o]t|�}|djott|g||��Sq�t|g||�}t	|�Sq[q[Wt|�S(slReturn the canonical path of the specified filename, eliminating any
symbolic links encountered in the path.R&iR*iiN(
RRtrangeR1RR
t
_resolve_linktNoneRR#(R@tbitsR3t	componenttresolvedtnewpath((s/sys/lib/python/posixpath.pyR#�s


cCs�g}x�t|�os||jodSn|i|�ti|�}t|�p%t|�}tt||��}q	t|�}q	W|S(s�Internal helper function.  Takes a path and follows symlinks
    until we either arrive at something that isn't a symlink, or
    encounter a path we've seen before (meaning that there's a loop).
    N(	R
R~RuR=treadlinkRRRR(R.t
paths_seenR�tdir((s/sys/lib/python/posixpath.pyR}�s


(-t__doc__R=R>t__all__RRR!RRRR~R R"RRRRRRRRRR	R
RRR
RRRRRRRRRRRnRRRR#R}RGR$(((s/sys/lib/python/posixpath.pys<module>s`							
				
							
	
		
	
				'		 		
		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.