
    F\hG                        S r SrSrSrSrSrSrSrSrSSK	r	SSK
r
SSKrSSKrSSKrSS	K7  / S
QrS rS rS rS rS rS r\R*                  R                   \l         S r SSKJr  S rS rS rS rSqSq S r! SSKJ"r#  S r$SS.S jr%\RL                  S:H  r'S"S  jr(S! r)g! \ a    S r NGf = f! \ a    S r# N<f = f)#a  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. Windows),
os.path provides the same operations in a manner specific to that
platform, and is an alias to another module (e.g. ntpath).

Some of this can actually be useful on non-Posix systems too, e.g.
for manipulation of the pathname component of URLs.
.../:z/bin:/usr/binNz	/dev/null    )*)*normcaseisabsjoin
splitdrive	splitrootsplitsplitextbasenamedirnamecommonprefixgetsizegetmtimegetatimegetctimeislinkexistslexistsisdirisfileismount
expanduser
expandvarsnormpathabspathsamefilesameopenfilesamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath
commonpath
isjunction
isdevdriveALLOW_MISSINGc                 0    [        U [        5      (       a  gg)N   /r   )
isinstancebytespaths     /usr/lib/python3.13/posixpath.py_get_sepr9   *   s    $    c                 .    [         R                  " U 5      $ )z6Normalize case of pathname.  Has no effect under Posixosfspath)ss    r8   r   r   5   s    99Q<r:   c                 f    [         R                  " U 5      n [        U 5      nU R                  U5      $ )zTest whether a path is absolute)r=   r>   r9   
startswith)r?   r%   s     r8   r	   r	   =   s'    
		!A
1+C<<r:   c                 x   [         R                  " U 5      n [        U 5      nU n U H]  n[         R                  " U5      nUR                  U5      (       d  U(       d  UnM:  UR	                  U5      (       a  X4-  nMV  X2U-   -  nM_     U$ ! [
        [        [        4 a    [        R                  " SU /UQ76   e f = f)zJoin 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
   )
r=   r>   r9   rA   endswith	TypeErrorAttributeErrorBytesWarninggenericpath_check_arg_types)apr%   r7   bs        r8   r
   r
   H   s    
 			!A
1+CDA		!A||C  s##	a  K ~|4 $$VQ33s   A#B
 
/B9c                     [         R                  " U 5      n [        U 5      nU R                  U5      S-   nU SU XS pCU(       a"  X1[	        U5      -  :w  a  UR                  U5      nX44$ )z|Split a pathname.  Returns tuple "(head, tail)" where "tail" is
everything after the final slash.  Either part may be empty.   Nr=   r>   r9   rfindlenrstrip)rJ   r%   iheadtails        r8   r   r   d   sc     			!A
1+C	qA2A"$CI%{{3:r:   c                     [         R                  " U 5      n [        U [        5      (       a  SnSnOSnSn[        R
                  " XS U5      $ )Nr3      .r   r   )r=   r>   r4   r5   rG   	_splitext)rJ   r%   r)   s      r8   r   r   u   sE    
		!A!U  v66r:   c                 <    [         R                  " U 5      n U SS U 4$ )zFSplit a pathname into drive and path. On Posix, drive is always
empty.Nr   r<   )rJ   s    r8   r   r      s      			!ARa5!8Or:   )_path_splitroot_exc                     [         R                  " U 5      n [        U [        5      (       a  SnSnOSnSnU SS U:w  a  X"U 4$ U SS U:w  d	  U SS U:X  a  X!U SS 4$ X SS U SS 4$ )	zWSplit a pathname into drive, root and tail.

The tail contains anything after the root.r3   r:   r    NrM         )r=   r>   r4   r5   )rJ   r%   emptys      r8   r   r      s     IIaLaCECERa5C<?"qVs]a!fmqu$$ BQ%12&&r:   c                 t    [         R                  " U 5      n [        U 5      nU R                  U5      S-   nXS $ )z)Returns the final component of a pathnamerM   N)r=   r>   r9   rO   )rJ   r%   rR   s      r8   r   r      s3    
		!A
1+C	qAR5Lr:   c                     [         R                  " U 5      n [        U 5      nU R                  U5      S-   nU SU nU(       a"  X1[	        U5      -  :w  a  UR                  U5      nU$ )z-Returns the directory component of a pathnamerM   NrN   )rJ   r%   rR   rS   s       r8   r   r      sX    
		!A
1+C	qARa5DCI%{{3Kr:   c                 X    [         R                  " U 5      n[        R                  " UR                  5      (       a  g [         R                  " U 5      n [        U [        5      (       a  [        U S5      nO[        U S5      n [         R                  " U5      nUR                  UR                  :g  =(       d    UR                  UR                  :H  $ ! [
        [        4 a     gf = f! [
         a6    [        U5      n [         R                  " U5      n N}! [
         a      gf = ff = f)z$Test whether a path is a mount pointF   ..r   )r=   lstatstatS_ISLNKst_modeOSError
ValueErrorr>   r4   r5   r
   r+   st_devst_ino)r7   s1parents2s       r8   r   r      s    XXd^ <<

## $ 99T?D$dE"dD!XXf 99		!;RYY"))%;;/ Z    &!	&!B 			s;   C C) C&%C&)D)?D
D%!D)$D%%D)c                    [         R                  " U 5      n [        U [        5      (       a  SnOSnU R	                  U5      (       d  U $ [        U 5      nU R                  US5      nUS:  a  [        U 5      nUS:X  a]  S[         R                  ;  a5   SSK	n UR                  [         R                  " 5       5      R                  nOg[         R                  S   nOS SSK	nU SU n[        U[        5      (       a  [         R                  " U5      n UR!                  U5      nUR                  nUc  ["        R$                  S:X  a  U $ [        U [        5      (       a  [         R&                  " U5      nUR)                  U5      nXPUS -   =(       d    U$ ! [         a    U s $ f = f! [         a    U s $ f = f! [         a    U s $ f = f! [         a    U s $ f = f)zKExpand ~ and ~user constructions.  If user or $HOME is unknown,
do nothing.   ~~rM   r   HOMENvxworks)r=   r>   r4   r5   rA   r9   findrP   environpwdImportErrorgetpwuidgetuidpw_dirKeyErrorfsdecodegetpwnamsysplatformfsencoderQ   )r7   tilder%   rR   ru   userhomenamepwents           r8   r   r      s    99T?D$??5!!
4.C		#qA1uIAv#<<		4;; zz&)H	 AaydE"";;t$D	LL&E
 <<CLLI5$;;x(s#HABx'C'C  
     	K	  	 K	sH   F .F$ F6 G F! F!$F32F36GGGGc                 r   [         R                  " U 5      n [        U [        5      (       aY  SU ;  a  U $ [        (       d   SSKnUR                  SUR                  5      q[        R                  nSnSn[        [         SS5      nOWSU ;  a  U $ [        (       d   SSKnUR                  S	UR                  5      q
[        R                  nS
nSn[         R                  nSn U" X5      nU(       d   U $ UR                  S5      u  phUR                  S5      n	U	R                  U5      (       a  U	R                  U5      (       a  U	SS n	 Uc<  [         R                   " [         R                  [         R"                  " U	5         5      n
OXY   n
XS nU SU U
-   n [%        U 5      nX-  n M  ! [&         a    Un Nf = f)zVExpand shell variables of form $var and ${var}.  Unknown variables
are left unchanged.   $r   Ns   \$(\w+|\{[^}]*\})   {   }environb$z\$(\w+|\{[^}]*\}){}rM   )r=   r>   r4   r5   	_varprogbrecompileASCIIsearchgetattr_varprogrt   spangrouprA   rC   r   r{   rP   rz   )r7   r   r   startendrt   rR   mjr   valuerT   s               r8   r   r   "  s    99T?D$tKy

#8"((CI!!"j$/d?Kxzz"6AH**	A
4O" K! vvaywwqz??5!!dmmC&8&8":D	BJJr{{4/@$AB 8D8e#DD	ALD'   	A	s   AF' 'F65F6)_path_normpathc                    [         R                  " U 5      n [        U [        5      (       a  SnSnSnOSnSnSnU (       d  U$ [	        U 5      u  pEn U R                  U5      n/ nU H`  nU(       a  X:X  a  M  X:w  d  U(       d  U(       a  U(       a  US   U:X  a  UR                  U5        MG  U(       d  MP  UR                  5         Mb     UnXQR                  U5      -   n U =(       d    U$ )z0Normalize path, eliminating double slashes, etc.r3   rV   rb   r   r   r   r   )	r=   r>   r4   r5   r   r   appendpopr
   )	r7   r%   dotdotdot_initial_slashescomps	new_compscomps	            r8   r   r   [  s    yydE""CCFCCFJ#,T? D

3	D4;y	" 7  &  %0{sr:   c                 D   [         R                  " U 5      n [        U [        5      (       a6  U R	                  S5      (       d  [        [         R                  " 5       U 5      n O5U R	                  S5      (       d  [        [         R                  " 5       U 5      n [        U 5      $ )zReturn an absolute path.r3   r   )	r=   r>   r4   r5   rA   r
   getcwdbgetcwdr   r6   s    r8   r   r   x  si    99T?D$t$$

d+Ds##		T*DD>r:   F)strictc                t   [         R                  " U 5      n [        U [        5      (       a  SnSnSn[         R                  nOSnSnSn[         R
                  nU[        L a	  [        nSnOU(       a  SnO[        nS	nU R                  U5      S	S	S
2   n[        U5      n	U R                  U5      (       a  UOU" 5       n
0 nU	(       Ga  UR                  5       nUc  XUR                  5       '   M/  U	S-  n	U(       a  X:X  a  MB  X:X  a  U
S	U
R                  U5       =(       d    Un
Mf  X:X  a  X-   nOX-   U-   n [         R                  " U5      R                  n[         R"                  " U5      (       dk  U(       a_  U	(       aX  [         R$                  " U5      (       d=  [        [&        R(                  [         R*                  " [&        R(                  5      U5      eUn
GM  X;   a,  X   n
U
b  GM-  U(       a  [         R                   " U5        Un
GMO  [         R,                  " U5      nUR                  U5      (       a  Un
Uc&  S	X'   UR/                  U5        UR/                  S	5        UR                  U5      S	S	S
2   nUR1                  U5        U	[        U5      -  n	GM  U
$ ! U a     Of = fUn
U	(       a  GM  N)zlReturn the canonical path of the specified filename, eliminating any
symbolic links encountered in the path.r3   rV   rb   r   r   r   T Nr   rM   )r=   r>   r4   r5   r   r   r1   FileNotFoundErrorrg   r   rP   rA   r   rindexrc   rf   rd   re   S_ISDIRerrnoENOTDIRstrerrorreadlinkr   extend)filenamer   r%   r#   r$   r   ignored_errormaxlinksrest
part_countr7   seenr   newpathrf   targettarget_partss                    r8   r+   r+     sk    yy"H(E"")	H >>#tt$D TJ %%c**3D D
xxz<#a
t~>)S)*1cD;kGj4'G(	hhw'//G<<((jg1F1F!%--U]]1K")+ +}#GGG$[[)F
   %% $ G$D!!<<,TrT2LKK%#l++J K/  		* y *s%   8B#J! J! -J! J! !J*)J*darwinc                    [         R                  " U 5      n U (       d  [        S5      e[        U [        5      (       a  SnSnSnOSnSnSnUc  UnO[         R                  " U5      n [        U5      R                  U5      n[        U 5      R                  U5      nU(       a  UR                  U5      O/ nU(       a  UR                  U5      O/ n[        [        Xx/5      5      n	U/[        U5      U	-
  -  XS -   n
U
(       d  U$ UR                  U
5      $ ! [        [        [        [        4 a    [        R                   " S	X5        e f = f)
z#Return a relative version of a pathzno path specifiedrV   r3   rb   r   r   r   Nr-   )r=   r>   rh   r4   r5   r   lstripr   rP   r   r
   rD   rE   rF   DeprecationWarningrG   rH   )r7   r   r#   r%   r$   
start_tail	path_tail
start_list	path_listrR   rel_lists              r8   r-   r-     s)    99T?D,--$}		% U^**3/
DM((-	.8Z%%c*b
,5IOOC(2	j4568s:q01IbMAMxx!!~|5GH $$Y<s   (BD D 3E	c           	         [        [        [        R                  U 5      5      n U (       d  [	        S5      e[        U S   [        5      (       a  SnSnOSnSn U  Vs/ s H  o3R                  U5      PM     nn U  Vs1 s H  oUR                  U5      iM     snu  nU VVs/ s H$  ow Vs/ s H  o(       d  M  X:w  d  M  UPM     snPM&     nnn[        U5      n	[        U5      n
U	n[        U	5       H  u  pXU   :w  d  M  U	SU n  O   U(       a  UOUSS nXR                  U5      -   $ s  snf s  snf ! [         a    [	        S5      Sef = fs  snf s  snnf ! [        [        4 a    [        R                   " S	/U Q76   e f = f)
zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencer   r3   rV   r   r   z%Can't mix absolute and relative pathsNr.   )tuplemapr=   r>   rh   r4   r5   r   rA   minmax	enumerater
   rD   rE   rG   rH   )pathsr%   r#   r7   split_pathsrJ   r	   r?   crk   rm   commonrR   prefixs                 r8   r.   r.   !  s}    #bii'(E@AA%(E""38954zz#59	P167All3'7FE EPPKq1:1aak1:KPbMDAqEzBQ "
 3r7(((# : 8 	PDE4O	P ;P ~& $$\:E:s~   E D+6E 9D5 =D0D5 E !	E*
E8E?EE1E )E +E 0D5 5EE EE )F)N)*__doc__r#   r$   r)   r%   r&   r'   r(   r*   r   r=   r}   rd   rG   __all__r9   r   r	   r
   r   r   rW   r   posixrY   r   rv   r   r   r   r   r   r   r   r   r   r   r+   r~   r,   r-   r.   r   r:   r8   <module>r      s  
 
			

	
  	 
   D8	"7 ((00 
'56<N3(t 	.j0@	 "' jZ "llh6 #V$k  '''\  s$   !B# ;B2 #	B/.B/2	B>=B>