B
    4[                 @   s  d dl Z d dlZyd dlmZ W nJ ek
rj   yd dlmZ W n$ ek
rd   G dd deZY nX Y nX ddddd	d
ddddddgZdd Zd#ddZ	d$ddZ
d%ddZd&ddZd'ddZd(dd	Zd)dd
ZdZd*ddZd+ddZd,ddZd-d dZd.d!dZd/d"dZdS )0    N)Pathc               @   s   e Zd ZdZdS )r   zDummy for isinstance checksN)__name__
__module____qualname____doc__ r   r   /lib/python3.7/site-packages/testpath/asserts.pyr      s   r   assert_path_existsassert_not_path_existsassert_isfileassert_not_isfileassert_isdirassert_not_isdirassert_islinkassert_not_islinkassert_ispipeassert_not_ispipeassert_issocketassert_not_issocketc             C   s   t | trt| S | S )N)
isinstancer   str)pr   r   r   _strpath   s    
r   Tc             C   sJ   |r
t jnt j}y|| S  tk
rD   |d kr8d|  }t|Y nX d S )Nz,Path does not exist, or can't be stat-ed: %r)osstatlstatOSErrorAssertionError)pathfollow_symlinksmsgr   r   r   r   _stat_for_assert   s    r!   c             C   s   t t| d| dS )z4Assert that something exists at the given path.
    TN)r!   r   )r   r    r   r   r   r	   &   s    c             C   s0   t | } tj| r,|dkr$d|  }t|dS )z2Assert that nothing exists at the given path.
    NzPath exists: %r)r   r   r   existsr   )r   r    r   r   r   r
   +   s
    c             C   s<   t | } t| ||}t|js8|dkr0d|  }t|dS )zAssert that path exists and is a regular file.
    
    With follow_symlinks=True, the default, this will pass if path is a symlink
    to a regular file. With follow_symlinks=False, it will fail in that case.
    Nz*Path exists, but is not a regular file: %r)r   r!   r   S_ISREGst_moder   )r   r   r    str   r   r   r   4   s    c             C   s<   t | } t| ||}t|jr8|dkr0d|  }t|dS )zAssert that path exists but is not a regular file.
    
    With follow_symlinks=True, the default, this will fail if path is a symlink
    to a regular file. With follow_symlinks=False, it will pass in that case.
    NzPath is a regular file: %r)r   r!   r   r#   r$   r   )r   r   r    r%   r   r   r   r   A   s    c             C   s<   t | } t| ||}t|js8|dkr0d|  }t|dS )zAssert that path exists and is a directory.
    
    With follow_symlinks=True, the default, this will pass if path is a symlink
    to a directory. With follow_symlinks=False, it will fail in that case.
    Nz'Path exists, but is not a directory: %r)r   r!   r   S_ISDIRr$   r   )r   r   r    r%   r   r   r   r   N   s    c             C   s<   t | } t| ||}t|jr8|dkr0d|  }t|dS )zAssert that path exists but is not a directory.
    
    With follow_symlinks=True, the default, this will fail if path is a symlink
    to a directory. With follow_symlinks=False, it will pass in that case.
    NzPath is a directory: %r)r   r!   r   r&   r$   r   )r   r   r    r%   r   r   r   r   [   s    zFSymlink target of:
  {path}
Expected:
  {expected}
Actual:
  {actual}
c             C   s~   t | } t| d|}t|js8|dkr0d|  }t||dk	rzt |}t| }||krz|dkrrtj	| ||d}t|dS )z|Assert that path exists and is a symlink.
    
    If to is specified, also check that it is the target of the symlink.
    FNz%Path exists, but is not a symlink: %r)r   ZexpectedZactual)
r   r!   r   S_ISLNKr$   r   r   readlink_link_target_msgformat)r   tor    r%   targetr   r   r   r   p   s    
c             C   s<   t | } t| d|}t|jr8|dkr0d|  }t|dS )z2Assert that path exists but is not a symlink.
    FNzPath is a symlink: %r)r   r!   r   r'   r$   r   )r   r    r%   r   r   r   r      s    c             C   s<   t | } t| ||}t|js8|dkr0d|  }t|dS )zAssert that path exists and is a named pipe (FIFO).

    With follow_symlinks=True, the default, this will pass if path is a symlink
    to a named pipe. With follow_symlinks=False, it will fail in that case.
    Nz(Path exists, but is not a named pipe: %r)r   r!   r   S_ISFIFOr$   r   )r   r   r    r%   r   r   r   r      s    c             C   s<   t | } t| ||}t|jr8|dkr0d|  }t|dS )zAssert that path exists but is not a named pipe (FIFO).

    With follow_symlinks=True, the default, this will fail if path is a symlink
    to a named pipe. With follow_symlinks=False, it will pass in that case.
    NzPath is a named pipe: %r)r   r!   r   r-   r$   r   )r   r   r    r%   r   r   r   r      s    c             C   s<   t | } t| ||}t|js8|dkr0d|  }t|dS )zAssert that path exists and is a Unix domain socket.

    With follow_symlinks=True, the default, this will pass if path is a symlink
    to a Unix domain socket. With follow_symlinks=False, it will fail in that case.
    Nz$Path exists, but is not a socket: %r)r   r!   r   S_ISSOCKr$   r   )r   r   r    r%   r   r   r   r      s    c             C   s<   t | } t| ||}t|jr8|dkr0d|  }t|dS )zAssert that path exists but is not a Unix domain socket.

    With follow_symlinks=True, the default, this will fail if path is a symlink
    to a Unix domain socket. With follow_symlinks=False, it will pass in that case.
    NzPath is a socket: %r)r   r!   r   r.   r$   r   )r   r   r    r%   r   r   r   r      s    )TN)N)N)TN)TN)TN)TN)NN)N)TN)TN)TN)TN)r   r   Zpathlibr   ImportErrorZpathlib2object__all__r   r!   r	   r
   r   r   r   r   r)   r   r   r   r   r   r   r   r   r   r   <module>   s:   
	

	









