o
    pf$                     @   s@  d Z ddlmZ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 d/d0 d0e Z#G d1d2 d2e"Z$G d3d4 d4e"Z%G d5d6 d6e Z&G d7d8 d8e Z'G d9d: d:e Z(G d;d< d<e Z)G d=d> d>e Z*G d?d@ d@e+Z,G dAdB dBe+Z-dS )Ca  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.

    )print_functionunicode_literalsN)	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UnsupportedUnsupportedHashc                       (   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__ B/home/ertert/spirit/venv/lib/python3.10/site-packages/fs/errors.pyr(   <   s   zMissingInfoNamespace.__init__c                 C      t | | jffS N)typer&   r*   r.   r.   r/   
__reduce__B      zMissingInfoNamespace.__reduce____name__
__module____qualname____doc__r(   r4   __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 r1   )default_message_msgr'   r   r(   r*   r+   r,   r.   r/   r(   L   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__Q   s   zFSError.__str__c                 C   s$   | j jdi | j}d| jj|S )Nz{}({!r})r.   )r=   r)   r?   r-   r7   r>   r.   r.   r/   __repr__W   s   zFSError.__repr__r1   )	r7   r8   r9   r:   r<   r(   r@   rA   r;   r.   r.   r,   r/   r   F   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r7   r8   r9   r:   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 r1   )errorsr'   r   r(   )r*   rE   r,   r.   r/   r(   h   s   zBulkCopyFailed.__init__)r7   r8   r9   r:   r<   r(   r;   r.   r.   r,   r/   r   c   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+   rH   r.   r.   r/   r(   r   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)rH   )	Exception)argskwargseclsfuncr.   r/   new_funcz   s   
z(CreateFailed.catch_all.<locals>.new_func)	functoolswraps)rN   rO   rP   r.   rM   r/   	catch_allx   s   zCreateFailed.catch_allc                 C   s   t | | j| jffS r1   )r2   r=   rH   r3   r.   r.   r/   r4      s   zCreateFailed.__reduce__NN)	r7   r8   r9   r:   r<   r(   classmethodrS   r4   r.   r.   r.   r/   r   m   s    

r   c                       .   e Zd ZdZdZd fdd	Zdd Z  ZS )	r   z3Base exception for errors to do with a path string.zpath '{path}' is invalidNc                    s"   || _ || _tt| j|d d S Nr+   )pathrH   r'   r   r(   )r*   rY   r+   rH   r,   r.   r/   r(         zPathError.__init__c                 C      t | | j| j| jffS r1   )r2   rY   r=   rH   r3   r.   r.   r/   r4         zPathError.__reduce__rT   r7   r8   r9   r:   r<   r(   r4   r;   r.   r.   r,   r/   r      
    r   c                   @   rB   )r   z<The filesystem does not provide *sys paths* to the resource.z2path '{path}' does not map to the local filesystemNrC   r.   r.   r.   r/   r      rD   r   c                       rV   )	r   z8The filesystem does not provide an URL for the resource.z$path '{path}' has no '{purpose}' URLNc                    s   || _ tt| j||d d S rW   )purposer'   r   r(   )r*   rY   r_   r+   r,   r.   r/   r(      s   zNoURL.__init__c                 C   r[   r1   )r2   rY   r_   r=   r3   r.   r.   r/   r4      r\   zNoURL.__reduce__r1   r]   r.   r.   r,   r/   r      s
    r   c                   @   rB   )r   z6Path can't be mapped on to the underlaying filesystem.z,path '{path}' is invalid on this filesystem NrC   r.   r.   r.   r/   r      rD   r   c                   @   rB   )r   z=Path contains characters that are invalid on this filesystem.z)path '{path}' contains invalid charactersNrC   r.   r.   r.   r/   r      rD   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 )NrF   errnorX   )	rY   rH   r   rG   getattrr`   r'   r   r(   r*   rY   rH   r+   r,   r.   r/   r(      s
   zOperationFailed.__init__c                 C   r[   r1   r2   rY   rH   r=   r3   r.   r.   r/   r4      r\   zOperationFailed.__reduce__)NNNr]   r.   r.   r,   r/   r      s    r   c                   @   rB   )r#   z*Operation not supported by the filesystem.znot supportedNrC   r.   r.   r.   r/   r#      rD   r#   c                   @   rB   )r   z1Operations encountered remote connection trouble.zremote connection errorNrC   r.   r.   r.   r/   r      rD   r   c                   @   rB   )r   z0Storage is insufficient for requested operation.zinsufficient storage spaceNrC   r.   r.   r.   r/   r      rD   r   c                   @   rB   )r   zNot enough permissions.zpermission deniedNrC   r.   r.   r.   r/   r      rD   r   c                   @   rB   )r   zFilesystem took too long.zoperation timed outNrC   r.   r.   r.   r/   r      rD   r   c                   @   rB   )r   z%Attempt to remove the root directory.z!root directory may not be removedNrC   r.   r.   r.   r/   r      rD   r   c                       rV   )	r   zCBase exception class for error associated with a specific resource.zfailed on path {path}Nc                    s"   || _ || _tt| j|d d S rW   )rY   rH   r'   r   r(   rb   r,   r.   r/   r(      rZ   zResourceError.__init__c                 C   r[   r1   rc   r3   r.   r.   r/   r4      r\   zResourceError.__reduce__rT   r]   r.   r.   r,   r/   r      r^   r   c                   @   rB   )r!   zRequired resource not found.zresource '{path}' not foundNrC   r.   r.   r.   r/   r!     rD   r!   c                   @   rB   )r   zResource has the wrong type.z/resource '{path}' is invalid for this operationNrC   r.   r.   r.   r/   r     rD   r   c                   @   rB   )r   zFile already exists.zresource '{path}' existsNrC   r.   r.   r.   r/   r     rD   r   c                   @   rB   )r   zOperation only works on files.zpath '{path}' should be a fileNrC   r.   r.   r.   r/   r     rD   r   c                   @   rB   )r   z$Operation only works on directories.z#path '{path}' should be a directoryNrC   r.   r.   r.   r/   r     rD   r   c                   @   rB   )r	   z"Target destination already exists.zdestination '{path}' existsNrC   r.   r.   r.   r/   r	     rD   r	   c                   @   rB   )r
   zDirectory already exists.zdirectory '{path}' existsNrC   r.   r.   r.   r/   r
   %  rD   r
   c                   @   rB   )r   z(Attempt to remove a non-empty directory.zdirectory '{path}' is not emptyNrC   r.   r.   r.   r/   r   +  rD   r   c                   @   rB   )r    z!Attempt to use a locked resource.zresource '{path}' is lockedNrC   r.   r.   r.   r/   r    1  rD   r    c                   @   rB   )r"   z*Attempting to modify a read-only resource.zresource '{path}' is read onlyNrC   r.   r.   r.   r/   r"   7  rD   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)rY   )rY   r)   r'   r   r(   )r*   rY   r+   r,   r.   r/   r(   J  s
   zIllegalBackReference.__init__c                 C   r0   r1   )r2   rY   r3   r.   r.   r/   r4   R  r5   zIllegalBackReference.__reduce__r6   r.   r.   r,   r/   r   =  s    r   c                   @   s   e Zd ZdZdS )r$   zThe requested hash algorithm is not supported.

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

    N)r7   r8   r9   r:   r.   r.   r.   r/   r$   V  s    r$   ).r:   
__future__r   r   typingrQ   sixr   TYPE_CHECKINGr   r   __all__AttributeErrorr   python_2_unicode_compatiblerI   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   r$   r.   r.   r.   r/   <module>   sP    
"
