B
    u9a=              &   @   sZ  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.g&Zd/d0 Zd1d	 Zd2d
 Zd3d Zd4d Zd5d Zejje_d6d Zd7d Zd8d Zd9d Zd:d Zd;d Zd<d Zdadad=d Zd>d Zd?d Z d@d+ Z!dAdB Z"e	j#dCkZ$dFdDd-Z%dEd. Z&dS )G.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
commonpathc             C   s   t | trdS dS d S )N   /r   )
isinstancebytes)path r0   /usr/lib/python3.7/posixpath.py_get_sep)   s    
r2   c             C   s.   t | } t| ttfs*td| jj| S )Nz2normcase() argument must be str or bytes, not '{}')	osfspathr-   r.   str	TypeErrorformat	__class____name__)sr0   r0   r1   r   4   s
    
c             C   s   t | } t| }| |S )N)r3   r4   r2   
startswith)r:   r"   r0   r0   r1   r   @   s    
c          
   G   s   t | } t| }| }yb|s,|d d |  xHtt j|D ]8}||rN|}q:|r\||rf||7 }q:||| 7 }q:W W n. tttfk
r   t	j
d| f|   Y nX |S )Nr   r   )r3   r4   r2   mapr;   endswithr6   AttributeErrorBytesWarninggenericpath_check_arg_types)apr"   r/   br0   r0   r1   r   K   s     


c             C   s`   t | } t| }| |d }| d | | |d   }}|rX||t| krX||}||fS )N   )r3   r4   r2   rfindlenrstrip)rC   r"   iheadtailr0   r0   r1   r
   h   s    

c             C   s6   t | } t| trd}d}nd}d}t| |d |S )Nr,      .r   r   )r3   r4   r-   r.   r@   	_splitext)rC   r"   r&   r0   r0   r1   r   y   s    

c             C   s   t | } | d d | fS )Nr   )r3   r4   )rC   r0   r0   r1   r	      s    
c             C   s,   t | } t| }| |d }| |d  S )NrE   )r3   r4   r2   rF   )rC   r"   rI   r0   r0   r1   r      s    
c             C   sN   t | } t| }| |d }| d | }|rJ||t| krJ||}|S )NrE   )r3   r4   r2   rF   rG   rH   )rC   r"   rI   rJ   r0   r0   r1   r      s    

c          	   C   s4   yt | }W n ttfk
r&   dS X t|jS )NF)r3   lstatOSErrorr>   statS_ISLNKst_mode)r/   str0   r0   r1   r      s
    c             C   s(   yt |  W n tk
r"   dS X dS )NFT)r3   rN   rO   )r/   r0   r0   r1   r      s
    c             C   s   yt | }W n tk
r"   dS X t|jr4dS t| trJt| d}n
t| d}t	|}yt |}W n tk
r~   dS X |j
}|j
}||krdS |j}|j}||krdS dS )NFs   ..z..T)r3   rN   rO   rP   rQ   rR   r-   r.   r   r(   st_devst_ino)r/   s1parents2dev1dev2ino1ino2r0   r0   r1   r      s.    

c       	      C   s4  t | } t| trd}nd}| |s,| S t| }| |d}|dk rPt| }|dkrdt jkrdd l	}y|
t  j}W q tk
r   | S X qt jd }nRdd l	}| d| }t|trt|d}y||}W n tk
r   | S X |j}t| trt |}d}nd}||}|| |d   p2|S )	N   ~~rE   r   HOMEASCIIr,   r   )r3   r4   r-   r.   r;   r2   findrG   environpwdgetpwuidgetuidpw_dirKeyErrorr5   getpwnamfsencoderH   )	r/   tilder"   rI   rc   userhomenamepwentrootr0   r0   r1   r      sB    







c             C   s\  t | } t| trVd| kr | S ts:dd l}|d|jatj}d}d}t	t dd }n:d| krb| S t
s|dd l}|d|ja
t
j}d	}d
}t j}d}x|| |}|sP |d\}}|d}	|	|r|	|r|	dd }	y.|d krt t jt |	 }
n||	 }
W n tk
r&   |}Y qX | |d  }| d | |
 } t| }| |7 } qW | S )N   $r   s   \$(\w+|\{[^}]*\})   {   }environb$z\$(\w+|\{[^}]*\}){}rE   )r3   r4   r-   r.   	_varprogbrecompiler`   searchgetattr_varprogrb   spangroupr;   r=   ri   fsdecoderg   rG   )r/   rx   rz   startendrb   rI   mjrl   valuerK   r0   r0   r1   r     sP    





c       	      C   s   t | } t| tr&d}d}d}d}nd}d}d}d}| |krB|S | |}|rp| |d	 rp| |d
 spd	}| |}g }xR|D ]J}|||fkrq||ks|s|r|r|d |kr|| q|r|  qW |}||} |r|| |  } | p|S )Nr,       rL   s   ..r    r   z..      rv   )	r3   r4   r-   r.   r;   r
   appendpopr   )	r/   r"   emptydotdotdotinitial_slashescomps	new_compscompr0   r0   r1   r   R  s>    





c             C   s@   t | } t| s8t| tr&t  }nt  }t|| } t| S )N)	r3   r4   r   r-   r.   getcwdbgetcwdr   r   )r/   cwdr0   r0   r1   r   x  s    



c             C   s*   t | } t| d d | i \}}t|S )Nr   )r3   r4   _joinrealpathr   )filenamer/   okr0   r0   r1   r(     s    
c       
      C   s  t | trd}d}d}nd}d}d}t|r<|dd  }|} x|r||\}}}|r>||krbq>||kr| rt| \} }||krt| ||} q>|} q>t| |}t|s|} q>||kr|| } | d k	rq>t||dfS d ||< t| t	||\} }	|	st| |dfS | ||< q>W | d	fS )
Nr,   rL   s   ..r   r   z..rE   FT)
r-   r.   r   	partitionr
   r   r   r   r3   readlink)
r/   restseenr"   r    r!   rl   _newpathr   r0   r0   r1   r     sH    

r   darwinc       	      C   s   | st dt| } t| tr.d}d}d}nd}d}d}|d krH|}n
t|}yndd	 t||D }d
d	 t| |D }tt||g}|gt||  ||d   }|s|S t	| S  t
tttfk
r   td| |  Y nX d S )Nzno path specifiedrL   r,   s   ..r   r   z..c             S   s   g | ]}|r|qS r0   r0   ).0xr0   r0   r1   
<listcomp>  s    zrelpath.<locals>.<listcomp>c             S   s   g | ]}|r|qS r0   r0   )r   r   r0   r0   r1   r     s    r*   )
ValueErrorr3   r4   r-   r.   r   r
   rG   r   r   r6   r>   r?   DeprecationWarningr@   rA   )	r/   r   r    r"   r!   
start_list	path_listrI   rel_listr0   r0   r1   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 qW |rn
d d }|| S  ttfk
r,   tjd|    Y nX d S )Nz%commonpath() arg is an empty sequencer   r,   rL   r   r   c                s   g | ]}|  qS r0   )r
   )r   r/   )r"   r0   r1   r     s    zcommonpath.<locals>.<listcomp>c             3   s   | ]}|d d  kV  qd S )NrE   r0   )r   rC   )r"   r0   r1   	<genexpr>   s    zcommonpath.<locals>.<genexpr>z%Can't mix absolute and relative pathsc                s   g | ]} fd d|D qS )c                s   g | ]}|r| kr|qS r0   r0   )r   c)r    r0   r1   r     s    z)commonpath.<locals>.<listcomp>.<listcomp>r0   )r   r:   )r    r0   r1   r     s    r+   )r+   )r   tupler<   r3   r4   r-   r.   setminmax	enumerater   r6   r>   r@   rA   )	pathssplit_pathsr   rV   rX   commonrI   r   prefixr0   )r    r"   r1   r+     s6    )N)'r    r!   r&   r"   r#   r$   r%   r'   r3   sysrP   r@   __all__r2   r   r   r   r
   r   rM   __doc__r	   r   r   r   r   r   r   r|   rw   r   r   r   r(   r   platformr)   r*   r+   r0   r0   r0   r1   <module>   sX   

	
	

*25&	3

)