
    ob$                        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e      Zej                   G d	 d
e             Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z  G d+ d,e       Z! G d- d.e       Z" G d/ d0e       Z# G d1 d2e"      Z$ G d3 d4e"      Z% G d5 d6e       Z& G d7 d8e       Z' G d9 d:e       Z( G d; d<e       Z) G d= d>e       Z* G d? d@e+      Z, G dA dBe+      Z-y)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Zd Z xZS )r   z!An expected namespace is missing.c                 \    || _         d}t        t        |   |j	                  |             y )Nz-namespace '{}' is required for this attribute)	namespacesuperr   __init__format)selfr(   msg	__class__s      +/usr/lib/python3/dist-packages/fs/errors.pyr*   zMissingInfoNamespace.__init__<   s(    "="D23::i3HI    c                 2    t        |       | j                  ffS N)typer(   r,   s    r/   
__reduce__zMissingInfoNamespace.__reduce__B   s    DzDNN,,,r0   __name__
__module____qualname____doc__r*   r5   __classcell__r.   s   @r/   r   r   9   s    +J-r0   r   c                   4     e Zd ZdZdZd fd	Zd Zd Z xZS )r   z#Base exception for the `fs` module.zUnspecified errorc                 T    |xs | j                   | _        t        t        |           y r2   )default_message_msgr)   r   r*   )r,   r-   r.   s     r/   r*   zFSError.__init__L   s"    /4//	gt%'r0   c                 R     | j                   j                  di | j                  }|S )zReturn the error message. )r@   r+   __dict__r,   r-   s     r/   __str__zFSError.__str__Q   s&     dii//
r0   c                      | j                   j                  di | j                  }dj                  | j                  j                  |      S )Nz{}({!r})rB   )r@   r+   rC   r.   r7   rD   s     r/   __repr__zFSError.__repr__W   s<    dii//  !8!8#>>r0   r2   )	r7   r8   r9   r:   r?   r*   rE   rG   r;   r<   s   @r/   r   r   F   s    -)O(
?r0   r   c                       e Zd ZdZdZy)r   z#Attempt to use a closed filesystem.z attempt to use closed filesystemNr7   r8   r9   r:   r?   rB   r0   r/   r   r   ]   s
    -8Or0   r   c                   &     e Zd ZdZdZ fdZ xZS )r   z*A copy operation failed in worker threads.z9One or more copy operations failed (see errors attribute)c                 8    || _         t        t        |           y r2   )errorsr)   r   r*   )r,   rL   r.   s     r/   r*   zBulkCopyFailed.__init__h   s    nd,.r0   )r7   r8   r9   r:   r?   r*   r;   r<   s   @r/   r   r   c   s    4QO/ /r0   r   c                   2    e Zd ZdZdZddZed        Zd Zy)r	   z Filesystem could not be created.z&unable to create filesystem, {details}Nc                 d    |xs | j                   | _        |dn
t        |      | _        || _        y )N )r?   r@   r   detailsexc)r,   r-   rQ   s      r/   r*   zCreateFailed.__init__r   s,    /4//	 [rinr0   c                 F     t        j                         fd       }|S )Nc                  T    	  | i |S # $ r  t         $ r} |      d }~ww xY w)N)rQ   )	Exception)argskwargseclsfuncs      r/   new_funcz(CreateFailed.catch_all.<locals>.new_funcz   s=    !T,V,,  !aj !s    '	"')	functoolswraps)rX   rY   rZ   s   `` r/   	catch_allzCreateFailed.catch_allx   s%    			! 
	! r0   c                 H    t        |       | j                  | j                  ffS r2   )r3   r@   rQ   r4   s    r/   r5   zCreateFailed.__reduce__   s    DzDIItxx000r0   NN)	r7   r8   r9   r:   r?   r*   classmethodr]   r5   rB   r0   r/   r	   r	   m   s(    *>O 
 
1r0   r	   c                   .     e Zd ZdZdZd fd	Zd Z xZS )r   z3Base exception for errors to do with a path string.zpath '{path}' is invalidc                 J    || _         || _        t        t        |   |       y Nr-   )pathrQ   r)   r   r*   )r,   re   r-   rQ   r.   s       r/   r*   zPathError.__init__   s#    	i'C'0r0   c                 ^    t        |       | j                  | j                  | j                  ffS r2   )r3   re   r@   rQ   r4   s    r/   r5   zPathError.__reduce__   s$    DzDIItyy$((;;;r0   r_   r7   r8   r9   r:   r?   r*   r5   r;   r<   s   @r/   r   r      s    =0O1<r0   r   c                       e Zd ZdZdZy)r   z<The filesystem does not provide *sys paths* to the resource.z2path '{path}' does not map to the local filesystemNrI   rB   r0   r/   r   r      s
    FJOr0   r   c                   .     e Zd ZdZdZd fd	Zd Z xZS )r   z8The filesystem does not provide an URL for the resource.z$path '{path}' has no '{purpose}' URLc                 >    || _         t        t        |   ||       y rc   )purposer)   r   r*   )r,   re   rk   r-   r.   s       r/   r*   zNoURL.__init__   s    eT#Dc#2r0   c                 ^    t        |       | j                  | j                  | j                  ffS r2   )r3   re   rk   r@   r4   s    r/   r5   zNoURL.__reduce__   s$    DzDIIt||TYY???r0   r2   rg   r<   s   @r/   r   r      s    B<O3
@r0   r   c                       e Zd ZdZdZy)r   z6Path can't be mapped on to the underlaying filesystem.z,path '{path}' is invalid on this filesystem NrI   rB   r0   r/   r   r      s
    @DOr0   r   c                       e Zd ZdZdZy)r   z=Path contains characters that are invalid on this filesystem.z)path '{path}' contains invalid charactersNrI   rB   r0   r/   r   r      s
    GAOr0   r   c                   4     e Zd ZdZdZ	 	 	 d fd	Zd Z xZS )r   zA specific operation failed.zoperation failed, {details}c                     || _         || _        |dn
t        |      | _        t	        |dd       | _        t        t        | #  |       y )NrO   errnord   )	re   rQ   r   rP   getattrrq   r)   r   r*   r,   re   rQ   r-   r.   s       r/   r*   zOperationFailed.__init__   sF     	 [rinS'40
ot-#-6r0   c                 ^    t        |       | j                  | j                  | j                  ffS r2   r3   re   rQ   r@   r4   s    r/   r5   zOperationFailed.__reduce__   $    DzDIItxx;;;r0   )NNNrg   r<   s   @r/   r   r      s     &3O 	7<r0   r   c                       e Zd ZdZdZy)r$   z*Operation not supported by the filesystem.znot supportedNrI   rB   r0   r/   r$   r$      s
    4%Or0   r$   c                       e Zd ZdZdZy)r   z1Operations encountered remote connection trouble.zremote connection errorNrI   rB   r0   r/   r   r      s
    ;/Or0   r   c                       e Zd ZdZdZy)r   z0Storage is insufficient for requested operation.zinsufficient storage spaceNrI   rB   r0   r/   r   r      s
    :2Or0   r   c                       e Zd ZdZdZy)r   zNot enough permissions.zpermission deniedNrI   rB   r0   r/   r   r      s
    !)Or0   r   c                       e Zd ZdZdZy)r   zFilesystem took too long.zoperation timed outNrI   rB   r0   r/   r   r      s
    #+Or0   r   c                       e Zd ZdZdZy)r   z%Attempt to remove the root directory.z!root directory may not be removedNrI   rB   r0   r/   r   r      s
    /9Or0   r   c                   .     e Zd ZdZdZd fd	Zd Z xZS )r   zCBase exception class for error associated with a specific resource.zfailed on path {path}c                 J    || _         || _        t        t        |   |       y rc   )re   rQ   r)   r   r*   rs   s       r/   r*   zResourceError.__init__   s#    	mT++4r0   c                 ^    t        |       | j                  | j                  | j                  ffS r2   ru   r4   s    r/   r5   zResourceError.__reduce__   rv   r0   r_   rg   r<   s   @r/   r   r      s    M-O5<r0   r   c                       e Zd ZdZdZy)r"   zRequired resource not found.zresource '{path}' not foundNrI   rB   r0   r/   r"   r"     s
    &3Or0   r"   c                       e Zd ZdZdZy)r    zResource has the wrong type.z/resource '{path}' is invalid for this operationNrI   rB   r0   r/   r    r      s
    &GOr0   r    c                       e Zd ZdZdZy)r   zFile already exists.zresource '{path}' existsNrI   rB   r0   r/   r   r     s
    0Or0   r   c                       e Zd ZdZdZy)r   zOperation only works on files.zpath '{path}' should be a fileNrI   rB   r0   r/   r   r     s
    (6Or0   r   c                       e Zd ZdZdZy)r   z$Operation only works on directories.z#path '{path}' should be a directoryNrI   rB   r0   r/   r   r     s
    .;Or0   r   c                       e Zd ZdZdZy)r
   z"Target destination already exists.zdestination '{path}' existsNrI   rB   r0   r/   r
   r
     s
    ,3Or0   r
   c                       e Zd ZdZdZy)r   zDirectory already exists.zdirectory '{path}' existsNrI   rB   r0   r/   r   r   %  s
    #1Or0   r   c                       e Zd ZdZdZy)r   z(Attempt to remove a non-empty directory.zdirectory '{path}' is not emptyNrI   rB   r0   r/   r   r   +  s
    27Or0   r   c                       e Zd ZdZdZy)r!   z!Attempt to use a locked resource.zresource '{path}' is lockedNrI   rB   r0   r/   r!   r!   1  s
    +3Or0   r!   c                       e Zd ZdZdZy)r#   z*Attempting to modify a read-only resource.zresource '{path}' is read onlyNrI   rB   r0   r/   r#   r#   7  s
    46Or0   r#   c                   (     e Zd ZdZ fdZd Z xZS )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                 ^    || _         dj                  |      }t        t        |   |       y )Nz<path '{path}' contains back-references outside of filesystem)re   )re   r+   r)   r   r*   )r,   re   r-   r.   s      r/   r*   zIllegalBackReference.__init__J  s5    	MUU V 
 	"D237r0   c                 2    t        |       | j                  ffS r2   )r3   re   r4   s    r/   r5   zIllegalBackReference.__reduce__R  s    DzDII<''r0   r6   r<   s   @r/   r   r   =  s    
8(r0   r   c                       e Zd ZdZy)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:   rB   r0   r/   r%   r%   V  s    r0   r%   ).r:   
__future__r   r   typingr[   sixr   TYPE_CHECKINGr   r   __all__AttributeErrorr   python_2_unicode_compatiblerT   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%   rB   r0   r/   <module>r      s   8   
 	%D
-> 
-   ?i ? !?,9w 9/W /17 18< <K	 K@I @E) EB B<g <,&/ &0O 03/ 3* *, ,:o :<G <4} 4Hm H1 17? 7< <4 42m 28 84] 47} 7(: (2j r0   