o
    Q `#                     @   sH  d Z ddlmZ ddlmZ ddlZddlZddlZddlmZ ejr+ddlm	Z	m
Z
 g dZG dd	 d	eZejG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZG d&d' d'eZG d(d) d)eZG d*d+ d+eZ G d,d- d-e Z!G d.d/ d/e Z"G d0d1 d1e Z#G d2d3 d3e"Z$G d4d5 d5e"Z%G d6d7 d7e Z&G d8d9 d9e Z'G d:d; d;e Z(G d<d= d=e Z)G d>d? d?e Z*G d@dA dAe+Z,G dBdC dCe+Z-dS )Da  Exception classes thrown by filesystem operations.

Errors relating to the underlying filesystem are translated in
to one of the following exceptions.

All Exception classes are derived from `~fs.errors.FSError`
which may be used as a catch-all filesystem exception.

    )unicode_literals)print_functionN)	text_type)OptionalText)BulkCopyFailedCreateFailedDestinationExistsDirectoryExistsDirectoryExpectedDirectoryNotEmpty
FileExistsFileExpectedFilesystemClosedFSErrorIllegalBackReferenceInsufficientStorageInvalidCharsInPathInvalidPathMissingInfoNamespace	NoSysPathNoURLOperationFailedOperationTimeout	PathErrorPermissionDeniedRemoteConnectionErrorRemoveRootErrorResourceErrorResourceInvalidResourceLockedResourceNotFoundResourceReadOnlyUnsupportedc                       (   e Zd ZdZ fddZdd Z  ZS )r   z&An expected namespace is missing.
    c                    s$   || _ d}tt| || d S )Nz-namespace '{}' is required for this attribute)	namespacesuperr   __init__format)selfr%   msg	__class__ +/usr/lib/python3/dist-packages/fs/errors.pyr'   =   s   zMissingInfoNamespace.__init__c                 C      t | | jffS N)typer%   r)   r-   r-   r.   
__reduce__C      zMissingInfoNamespace.__reduce____name__
__module____qualname____doc__r'   r3   __classcell__r-   r-   r+   r.   r   9   s    r   c                       s6   e Zd ZdZdZd
 fdd	Zdd Zdd	 Z  ZS )r   z(Base exception for the `fs` module.
    zUnspecified errorNc                    s   |p| j | _tt|   d S r0   )default_message_msgr&   r   r'   r)   r*   r+   r-   r.   r'   N   s   zFSError.__init__c                 C   s   | j jdi | j}|S )z"Return the error message.
        Nr-   )r<   r(   __dict__r=   r-   r-   r.   __str__S   s   zFSError.__str__c                 C   s$   | j jdi | j}d| jj|S )Nz{}({!r})r-   )r<   r(   r>   r,   r6   r=   r-   r-   r.   __repr__Z   s   zFSError.__repr__r0   )	r6   r7   r8   r9   r;   r'   r?   r@   r:   r-   r-   r+   r.   r   G   s    r   c                   @      e Zd ZdZdZdS )r   z(Attempt to use a closed filesystem.
    z attempt to use closed filesystemNr6   r7   r8   r9   r;   r-   r-   r-   r.   r   `       r   c                       s$   e Zd ZdZdZ fddZ  ZS )r   z*A copy operation failed in worker threads.z9One or more copy operations failed (see errors attribute)c                    s   || _ tt|   d S r0   )errorsr&   r   r'   )r)   rD   r+   r-   r.   r'   l   s   zBulkCopyFailed.__init__)r6   r7   r8   r9   r;   r'   r:   r-   r-   r+   r.   r   g   s    r   c                   @   s2   e Zd ZdZdZd
ddZedd Zdd	 ZdS )r   z%Filesystem could not be created.
    z&unable to create filesystem, {details}Nc                 C   s,   |p| j | _|d u rdnt|| _|| _d S )N )r;   r<   r   detailsexc)r)   r*   rG   r-   r-   r.   r'   w   s   
zCreateFailed.__init__c                    s   t  fdd}|S )Nc               
      sB   z| i |W S   y     t y  } z |dd }~ww )N)rG   )	Exception)argskwargseclsfuncr-   r.   new_func   s   
z(CreateFailed.catch_all.<locals>.new_func)	functoolswraps)rM   rN   rO   r-   rL   r.   	catch_all}   s   zCreateFailed.catch_allc                 C      t | | j| jffS r0   )r1   r<   rG   r2   r-   r-   r.   r3         zCreateFailed.__reduce__NN)	r6   r7   r8   r9   r;   r'   classmethodrR   r3   r-   r-   r-   r.   r   q   s    

r   c                       .   e Zd ZdZdZd fdd	Zdd Z  ZS )	r   z8Base exception for errors to do with a path string.
    zpath '{path}' is invalidNc                    s   || _ tt| j|d d S Nr*   )pathr&   r   r'   r)   rZ   r*   r+   r-   r.   r'      s   zPathError.__init__c                 C   rS   r0   )r1   rZ   r<   r2   r-   r-   r.   r3      rT   zPathError.__reduce__r0   r6   r7   r8   r9   r;   r'   r3   r:   r-   r-   r+   r.   r      
    r   c                   @   rA   )r   zAThe filesystem does not provide *sys paths* to the resource.
    z2path '{path}' does not map to the local filesystemNrB   r-   r-   r-   r.   r      rC   r   c                       rW   )	r   z=The filesystem does not provide an URL for the resource.
    z$path '{path}' has no '{purpose}' URLNc                    s   || _ tt| j||d d S rX   )purposer&   r   r'   )r)   rZ   r^   r*   r+   r-   r.   r'      s   zNoURL.__init__c                 C      t | | j| j| jffS r0   )r1   rZ   r^   r<   r2   r-   r-   r.   r3         zNoURL.__reduce__r0   r\   r-   r-   r+   r.   r      r]   r   c                   @   rA   )r   z;Path can't be mapped on to the underlaying filesystem.
    z,path '{path}' is invalid on this filesystem NrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   zBPath contains characters that are invalid on this filesystem.
    z)path '{path}' contains invalid charactersNrB   r-   r-   r-   r.   r      rC   r   c                       s4   e Zd ZdZdZ			d fdd	Zdd Z  ZS )	r   z!A specific operation failed.
    zoperation failed, {details}Nc                    sF   || _ || _|d u rdnt|| _t|dd | _tt| j|d d S )NrE   errnorY   )	rZ   rG   r   rF   getattrra   r&   r   r'   r)   rZ   rG   r*   r+   r-   r.   r'      s
   zOperationFailed.__init__c                 C   r_   r0   r1   rZ   rG   r<   r2   r-   r-   r.   r3      r`   zOperationFailed.__reduce__)NNNr\   r-   r-   r+   r.   r      s    r   c                   @   rA   )r#   z/Operation not supported by the filesystem.
    znot supportedNrB   r-   r-   r-   r.   r#      rC   r#   c                   @   rA   )r   z6Operations encountered remote connection trouble.
    zremote connection errorNrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   z5Storage is insufficient for requested operation.
    zinsufficient storage spaceNrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   zNot enough permissions.
    zpermission deniedNrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   zFilesystem took too long.
    zoperation timed outNrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   z*Attempt to remove the root directory.
    z!root directory may not be removedNrB   r-   r-   r-   r.   r      rC   r   c                       rW   )	r   zHBase exception class for error associated with a specific resource.
    zfailed on path {path}Nc                    s"   || _ || _tt| j|d d S rX   )rZ   rG   r&   r   r'   rc   r+   r-   r.   r'     s   zResourceError.__init__c                 C   r_   r0   rd   r2   r-   r-   r.   r3     r`   zResourceError.__reduce__rU   r\   r-   r-   r+   r.   r     s
    r   c                   @   rA   )r!   z!Required resource not found.
    zresource '{path}' not foundNrB   r-   r-   r-   r.   r!     rC   r!   c                   @   rA   )r   z!Resource has the wrong type.
    z/resource '{path}' is invalid for this operationNrB   r-   r-   r-   r.   r     rC   r   c                   @   rA   )r   zFile already exists.
    zresource '{path}' existsNrB   r-   r-   r-   r.   r      rC   r   c                   @   rA   )r   z#Operation only works on files.
    zpath '{path}' should be a fileNrB   r-   r-   r-   r.   r   '  rC   r   c                   @   rA   )r   z)Operation only works on directories.
    z#path '{path}' should be a directoryNrB   r-   r-   r-   r.   r   .  rC   r   c                   @   rA   )r	   z'Target destination already exists.
    zdestination '{path}' existsNrB   r-   r-   r-   r.   r	   5  rC   r	   c                   @   rA   )r
   zDirectory already exists.
    zdirectory '{path}' existsNrB   r-   r-   r-   r.   r
   <  rC   r
   c                   @   rA   )r   z-Attempt to remove a non-empty directory.
    zdirectory '{path}' is not emptyNrB   r-   r-   r-   r.   r   C  rC   r   c                   @   rA   )r    z&Attempt to use a locked resource.
    zresource '{path}' is lockedNrB   r-   r-   r-   r.   r    J  rC   r    c                   @   rA   )r"   z/Attempting to modify a read-only resource.
    zresource '{path}' is read onlyNrB   r-   r-   r-   r.   r"   Q  rC   r"   c                       r$   )r   a  Too many backrefs exist in a path.

    This error will occur if the back references in a path would be
    outside of the root. For example, ``"/foo/../../"``, contains two back
    references which would reference a directory above the root.

    Note:
        This exception is a subclass of `ValueError` as it is not
        strictly speaking an issue with a filesystem or resource.

    c                    s&   || _ dj|d}tt| | d S )Nz<path '{path}' contains back-references outside of filesystem)rZ   )rZ   r(   r&   r   r'   r[   r+   r-   r.   r'   e  s
   zIllegalBackReference.__init__c                 C   r/   r0   )r1   rZ   r2   r-   r-   r.   r3   m  r4   zIllegalBackReference.__reduce__r5   r-   r-   r+   r.   r   X  s    r   c                   @   s   e Zd ZdZdS )UnsupportedHashzThe requested hash algorithm is not supported.

    This exception will be thrown if a hash algorithm is requested that is
    not supported by hashlib.

    N)r6   r7   r8   r9   r-   r-   r-   r.   re   q  s    re   ).r9   Z
__future__r   r   rP   typingZsixr   ZTYPE_CHECKINGr   r   __all__AttributeErrorr   Zpython_2_unicode_compatiblerH   r   r   r   r   r   r   r   r   r   r   r#   r   r   r   r   r   r   r!   r   r   r   r   r	   r
   r   r    r"   
ValueErrorr   re   r-   r-   r-   r.   <module>   sR    
!
