
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ct„jÄ?  ã            '   @   sf  d Z dZdZdZdZdZdZdZdZddl	Z	ddl
Z
ddlZddlZdd	lT d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0g'Zd1d2„ Zd3d
„ Zd4d„ Zd5d„ Zd6d„ Zd7d„ Zejj e_ d8d„ Zd9d„ Zd:d„ Zd;d„ Zd<d„ Zd=d„ Zd>d„ Zdadad?d„ Zd@d„ ZdAd „ Z dBdCœdDd,„Z!dEdF„ Z"e
j#dGkZ$dJdHd.„Z%dId/„ Z&dS )Kaç  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.
Ú.z..ú/ú:z:/bin:/usr/binNz	/dev/nullé    )Ú*ÚnormcaseÚisabsÚjoinÚ
splitdriveÚ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ÚALLOW_MISSINGc             C   s   t | tƒrdS dS d S )Nó   /r   )Ú
isinstanceÚbytes)Úpath© r1   ú!/usr/lib64/python3.6/posixpath.pyÚ_get_sep)   s    
r3   c             C   s.   t j| ƒ} t| ttfƒs*tdj| jjƒƒ‚| S )z6Normalize case of pathname.  Has no effect under Posixz2normcase() argument must be str or bytes, not '{}')	ÚosÚfspathr.   r/   ÚstrÚ	TypeErrorÚformatÚ	__class__Ú__name__)Úsr1   r1   r2   r   4   s
    
c             C   s   t j| ƒ} t| ƒ}| j|ƒS )zTest whether a path is absolute)r4   r5   r3   Ú
startswith)r;   r"   r1   r1   r2   r   @   s    
c             G   s®   t j| ƒ} t| ƒ}| }yd|s,|dd… |  xJtt j|ƒD ]:}|j|ƒrN|}q:| s^|j|ƒrh||7 }q:||| 7 }q:W W n. tttfk
r¨   t	j
d| f|žŽ  ‚ Y nX |S )zæ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.Nr   r   )r4   r5   r3   Úmapr<   Úendswithr7   ÚAttributeErrorÚBytesWarningÚgenericpathÚ_check_arg_types)ÚaÚpr"   r0   Úbr1   r1   r2   r   K   s     


c             C   s`   t j| ƒ} t| ƒ}| j|ƒd }| d|… | |d…  }}|rX||t|ƒ krX|j|ƒ}||fS )z€Split a pathname.  Returns tuple "(head, tail)" where "tail" is
    everything after the final slash.  Either part may be empty.é   N)r4   r5   r3   ÚrfindÚlenÚrstrip)rD   r"   ÚiÚheadÚtailr1   r1   r2   r
   h   s    

c             C   s6   t j| ƒ} t| tƒrd}d}nd}d}tj| |d |ƒS )Nr-   ó   .r   r   )r4   r5   r.   r/   rA   Ú	_splitext)rD   r"   r&   r1   r1   r2   r   y   s    

c             C   s   t j| ƒ} | dd… | fS )zJSplit a pathname into drive and path. On Posix, drive is always
    empty.Nr   )r4   r5   )rD   r1   r1   r2   r	   ‡   s    
c             C   s,   t j| ƒ} t| ƒ}| j|ƒd }| |d… S )z)Returns the final component of a pathnamerF   N)r4   r5   r3   rG   )rD   r"   rJ   r1   r1   r2   r   �   s    
c             C   sN   t j| ƒ} t| ƒ}| j|ƒd }| d|… }|rJ||t|ƒ krJ|j|ƒ}|S )z-Returns the directory component of a pathnamerF   N)r4   r5   r3   rG   rH   rI   )rD   r"   rJ   rK   r1   r1   r2   r   š   s    

c             C   s4   yt j| ƒ}W n ttfk
r&   dS X tj|jƒS )z&Test whether a path is a symbolic linkF)r4   ÚlstatÚOSErrorr?   ÚstatÚS_ISLNKÚst_mode)r0   Ústr1   r1   r2   r   ¨   s
    c             C   s(   yt j| ƒ W n tk
r"   dS X dS )zCTest whether a path exists.  Returns True for broken symbolic linksFT)r4   rO   rP   )r0   r1   r1   r2   r   ²   s
    c             C   s´   yt j| ƒ}W n tk
r"   dS X tj|jƒr4dS t| tƒrJt| dƒ}n
t| dƒ}t	|ƒ}yt j|ƒ}W n tk
r~   dS X |j
}|j
}||kr˜dS |j}|j}||kr°dS dS )z$Test whether a path is a mount pointFs   ..z..T)r4   rO   rP   rQ   rR   rS   r.   r/   r   r(   Úst_devÚst_ino)r0   Ús1ÚparentÚs2Údev1Údev2Úino1Úino2r1   r1   r2   r   ¾   s.    

c       	      C   s4  t j| ƒ} t| tƒrd}nd}| j|ƒs,| S t| ƒ}| j|dƒ}|dk rPt| ƒ}|dkr¢dt jkr–ddl	}y|j
t jƒ ƒj}W q  tk
r’   | S X qôt jd }nRddl	}| d|… }t|tƒrÊt|dƒ}y|j|ƒ}W n tk
rì   | S X |j}t| tƒ�rt j|ƒ}d}nd	}|j|ƒ}|| |d…  �p2|S )
zOExpand ~ and ~user constructions.  If user or $HOME is unknown,
    do nothing.ó   ~ú~rF   r   ÚHOMENÚASCIIr-   r   )r4   r5   r.   r/   r<   r3   ÚfindrH   ÚenvironÚpwdÚgetpwuidÚgetuidÚpw_dirÚKeyErrorr6   ÚgetpwnamÚfsencoderI   )	r0   Útilder"   rJ   rd   ÚuserhomeÚnameÚpwentÚrootr1   r1   r2   r   è   sB    







c             C   s\  t j| ƒ} t| tƒrVd| kr | S ts:ddl}|jd|jƒatj}d}d}t	t ddƒ}n:d| krb| S t
s|ddl}|jd	|jƒa
t
j}d
}d}t j}d}xÂ|| |ƒ}|s¦P |jdƒ\}}|jdƒ}	|	j|ƒrÞ|	j|ƒrÞ|	dd… }	y.|dk�rt jt jt j|	ƒ ƒ}
n||	 }
W n tk
�r&   |}Y q–X | |d… }| d|… |
 } t| ƒ}| |7 } q–W | S )zZExpand shell variables of form $var and ${var}.  Unknown variables
    are left unchanged.ó   $r   Ns   \$(\w+|\{[^}]*\})ó   {ó   }Úenvironbú$z\$(\w+|\{[^}]*\})ú{ú}rF   éÿÿÿÿ)r4   r5   r.   r/   Ú	_varprogbÚreÚcompilera   ÚsearchÚgetattrÚ_varprogrc   ÚspanÚgroupr<   r>   rj   Úfsdecoderh   rH   )r0   ry   r{   ÚstartÚendrc   rJ   ÚmÚjrm   ÚvaluerL   r1   r1   r2   r     sP    





c       	      C   sþ   t j| ƒ} t| tƒr&d}d}d}d}nd}d}d}d}| |krB|S | j|ƒ}|rr| j|d	 ƒrr| j|d
 ƒ rrd	}| j|ƒ}g }xV|D ]N}|||fkr˜q†||ks¼| r¬| s¼|rÈ|d |krÈ|j|ƒ q†|r†|jƒ  q†W |}|j|ƒ} |rö|| |  } | pü|S )z0Normalize path, eliminating double slashes, etc.r-   ó    rM   s   ..r   Ú r   z..é   é   rF   rw   )	r4   r5   r.   r/   r<   r
   ÚappendÚpopr   )	r0   r"   ÚemptyÚdotÚdotdotÚinitial_slashesÚcompsÚ	new_compsÚcompr1   r1   r2   r   R  s>    





c             C   s@   t j| ƒ} t| ƒs8t| tƒr&t jƒ }nt jƒ }t|| ƒ} t| ƒS )zReturn an absolute path.)	r4   r5   r   r.   r/   ÚgetcwdbÚgetcwdr   r   )r0   Úcwdr1   r1   r2   r   x  s    



F)Ústrictc            C   s,   t j| ƒ} t| dd… | |i ƒ\}}t|ƒS )zlReturn the canonical path of the specified filename, eliminating any
symbolic links encountered in the path.Nr   )r4   r5   Ú_joinrealpathr   )Úfilenamer–   r0   Úokr1   r1   r2   r(   ‡  s    
c             C   s�  t | tƒrd}d}d}nd}d}d}tj}|tkr8t}n|rBf }nt}d }	t|ƒrb|dd … }|} �x"|�r†|j|ƒ\}
}}|
 sf|
|krŒqf|
|krÀ| rºt	| ƒ\} }
|
|kr¾t
| ||ƒ} qf|} qft
| |
ƒ}ytj|ƒ}W n |k
rð   d}Y nX tj|jƒ}|�s
|} qf||k�rH|| } | d k	�r(qf|�r:tj|ƒ nt
||ƒdfS d ||< t| tj|ƒ||ƒ\} }|�s|t
| |ƒdfS | ||< qfW | d	fS )
Nr-   rM   s   ..r   r   z..rF   FT)r.   r/   r4   r”   r,   ÚFileNotFoundErrorrP   r   Ú	partitionr
   r   rO   rQ   rR   rS   r—   Úreadlink)r0   Úrestr–   Úseenr"   r    r!   r”   Úignored_errorÚmaxlinksrm   Ú_ÚnewpathrT   Úis_linkr™   r1   r1   r2   r—   �  sd    





r—   Údarwinc       	      C   sò   | st dƒ‚tj| ƒ} t| tƒr.d}d}d}nd}d}d}|dkrH|}n
tj|ƒ}ynd	d
„ t|ƒj|ƒD ƒ}dd
„ t| ƒj|ƒD ƒ}tt||gƒƒ}|gt|ƒ|  ||d…  }|sº|S t	|Ž S  t
tttfk
rì   tjd| |ƒ ‚ Y nX dS )z#Return a relative version of a pathzno path specifiedrM   r-   s   ..r   r   z..Nc             S   s   g | ]}|r|‘qS r1   r1   )Ú.0Úxr1   r1   r2   ú
<listcomp>î  s    zrelpath.<locals>.<listcomp>c             S   s   g | ]}|r|‘qS r1   r1   )r¥   r¦   r1   r1   r2   r§   ï  s    r*   )Ú
ValueErrorr4   r5   r.   r/   r   r
   rH   r   r   r7   r?   r@   ÚDeprecationWarningrA   rB   )	r0   r�   r    r"   r!   Ú
start_listÚ	path_listrJ   Úrel_listr1   r1   r2   r*   Ø  s0    


c       	         s2  | st dƒ‚tttj| ƒƒ} t| d tƒr4d‰d‰ nd‰d‰ yÆ‡fdd„| D ƒ}yt‡fd	d
„| D ƒƒ\}W n t k
rŠ   t dƒd‚Y nX ‡ fdd„|D ƒ}t|ƒ}t	|ƒ}|}x.t
|ƒD ]"\}}||| kr¼|d|… }P q¼W |rêˆn
ˆdd… }|ˆj|ƒ S  ttfk
�r,   tjd| žŽ  ‚ Y nX dS )zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencer   r-   rM   r   r   c                s   g | ]}|j ˆ ƒ‘qS r1   )r
   )r¥   r0   )r"   r1   r2   r§     s    zcommonpath.<locals>.<listcomp>c             3   s   | ]}|d d… ˆ kV  qd S )NrF   r1   )r¥   rD   )r"   r1   r2   ú	<genexpr>  s    zcommonpath.<locals>.<genexpr>z%Can't mix absolute and relative pathsNc                s   g | ]}‡ fd d„|D ƒ‘qS )c                s   g | ]}|r|ˆ kr|‘qS r1   r1   )r¥   Úc)r    r1   r2   r§     s    z)commonpath.<locals>.<listcomp>.<listcomp>r1   )r¥   r;   )r    r1   r2   r§     s    r+   )r+   )r¨   Útupler=   r4   r5   r.   r/   ÚsetÚminÚmaxÚ	enumerater   r7   r?   rA   rB   )	ÚpathsÚsplit_pathsr   rW   rY   ÚcommonrJ   r®   Úprefixr1   )r    r"   r2   r+     s6    )N)'Ú__doc__r    r!   r&   r"   r#   r$   r%   r'   r4   ÚsysrQ   rA   Ú__all__r3   r   r   r   r
   r   rN   r	   r   r   r   r   r   r   r}   rx   r   r   r   r(   r—   Úplatformr)   r*   r+   r1   r1   r1   r2   Ú<module>   sZ   

	
	

*25&	F

)