
    h                         S SK r S SKrS SKrS SKJr  S SKrS SKJr  S SKJ	r	J
r
JrJrJrJrJr  SSKJrJrJr  SSKJr  SSKJr  \" S	\S
9rS\S\
4S jr " S S\ R6                  \	\   5      rg)    N)Path)TemporaryDirectory)GenericCallableIterableOptionalTupleTypeVarUnion   )CloudImplementation	CloudPathimplementation_registry)FileCacheMode)InvalidConfigurationExceptionBoundedCloudPath)boundkeyreturnc                 0   ^  S[         S[         4U 4S jjnU$ )Nclsr   c                    > [        U [        5      (       d  [        S5      eU [        T   l        T[        T   l        [        T   U l        U $ )Nz,Only subclasses of Client can be registered.)
issubclassClient	TypeErrorr   _client_classname_cloud_meta)r   r   s    M/home/james-whalen/.local/lib/python3.13/site-packages/cloudpathlib/client.py	decorator(register_client_class.<locals>.decorator   sI    #v&&JKK58$2,/$)1#6
    )type)r   r    s   ` r   register_client_classr$      s    t   r"   c            
          \ rS rSr% \\S'   SrSS\R                  4S\	\
\\4      S\	\
\\R                  4      S\	\   4S jjrS!S	 jr\S"S
 j5       rS!S jrS\
\\4   S\S\4S jrS r\R2                  S\S\
\\R                  4   S\4S j5       r\R2                  S\S\4S j5       r\R2                  S\S\S\\\\4      4S j5       r \R2                   S#S\S\S\S\4S jj5       r!\R2                  S#S\S\SS4S jj5       r"\R2                  S\
\\R                  4   S\S\4S j5       r#\R2                  S\S\4S j5       r$\R2                   S$S\S\%S\4S jj5       r&S r'g)%r      r   Nfile_cache_modelocal_cache_dircontent_type_methodc                    S U l         S U l        U R                  R                  5         [	        U[
        5      (       a  [        U5      nUc  [        R                  " 5       nUc(  [        R                  R                  SS 5      nUS:X  a  S nU(       a  Uc  [        R                  nU[        R                  :X  a   Uc  [        S[        R                   S35      eUc8  [        5       U l        U R                  R                  nUc  [        R                  n[!        U5      U l        X0l        Uc  [        R                  nXl         g )NCLOUDPATHLIB_LOCAL_CACHE_DIR zIf you use the 'zP' cache mode, you must pass a `local_cache_dir` when you instantiate the client.)r'   _cache_tmp_dirr   validate_completeness
isinstancestrr   from_environmentosenvironget
persistentr   r   r   tmp_dirr   _local_cache_dirr)   )selfr'   r(   r)   s       r   __init__Client.__init__!   s/     $"..0 os+++O<O "+<<>O" jjnn-KTRO "$"& 6+66Om666?;R/"=#;#;"<  =M  N 
 ""4"6D"1166O&"/"7"7 $_ 5#6  "+33O.r"   r   c                    [        U SS 5      [        R                  [        R                  [        R                  4;   aK  U R                  5         U R                  R                  5       (       a  U R                  R                  5         g g g )Nr'   )	getattrr   r6   
close_filecloudpath_objectclear_cacher7   existsrmdirr8   s    r   __del__Client.__del__U   su     4*D1!!$$**6
 

 $$++--%%++- .
r"   c                 L    U R                   c  U " 5       U l         U R                   $ )zGet the default client, which the one that is used when instantiating a cloud path
instance for this cloud without a client specified.
)_default_client)r   s    r   get_default_clientClient.get_default_clientb   s&    
 &"%%C"""r"   c                 $    X R                   l        g)zSet this client instance as the default one used when instantiating cloud path
instances for this cloud without a client specified.N)	__class__rF   rB   s    r   set_as_default_clientClient.set_as_default_clientk   s     *.&r"   
cloud_pathpartsc                 B    U R                   R                  " U/UQ7SU 06$ )Nclient)r   
path_class)r8   rM   rN   s      r   r   Client.CloudPathp   s#    **:KKdKKr"   c                     U R                   R                  5       (       a_  U R                   R                  5        H@  nUR                  5       (       a  UR	                  5         M*  [
        R                  " U5        MB     gg)zaClears the contents of the cache folder.
Does not remove folder so it can keep being written to.
N)r7   r@   iterdiris_fileunlinkshutilrmtree)r8   ps     r   r?   Client.clear_caches   sW       ''))**22499;;HHJMM!$	 5 *r"   
local_pathc                     g N )r8   rM   r[   s      r   _download_fileClient._download_file~        	r"   c                     g r]   r^   r8   rM   s     r   _existsClient._exists       r"   	recursivec                     g)a'  List all the files and folders in a directory.

Parameters
----------
cloud_path : CloudPath
    The folder to start from.
recursive : bool
    Whether or not to list recursively.

Returns
-------
contents : Iterable[Tuple]
    Of the form [(CloudPath, is_dir), ...] for every child of the dir.
Nr^   )r8   rM   rg   s      r   	_list_dirClient._list_dir   s    $ 	r"   srcdst
remove_srcc                     g r]   r^   )r8   rk   rl   rm   s       r   
_move_fileClient._move_file   ra   r"   path
missing_okc                     g)zsRemove a file or folder from the server.

Parameters
----------
path : CloudPath
    The file or folder to remove.
Nr^   )r8   rq   rr   s      r   _removeClient._remove   s     	r"   c                     g r]   r^   )r8   r[   rM   s      r   _upload_fileClient._upload_file   ra   r"   c                     g r]   r^   rc   s     r   _get_public_urlClient._get_public_url   rf   r"   expire_secondsc                     g r]   r^   )r8   rM   r|   s      r   _generate_presigned_urlClient._generate_presigned_url   ra   r"   )r-   r7   r)   r'   )r   N)r   r   )T)i  )(__name__
__module____qualname____firstlineno__r   __annotations__rF   	mimetypes
guess_typer   r   r0   r   r2   PathLiker   r9   rC   classmethodrG   rK   r   r   r?   abcabstractmethodr   r_   boolrd   r   r	   ri   ro   rt   rw   rz   intr~   __static_attributes__r^   r"   r   r   r      sl   $$O @D=A2;2F2F	2/!%](:";<2/ "%R[[(8"9:2/ &h/	2/h. # #.
LE#/?*?$@ L# LRb L	% 	*8=c2;;>N8O	 
 	"2 t   	*7;	%($./	0 & 	OS#*:HL	 
 	, $ $   	R[[ 01?O	 
 	*: s   	BI*<?	 r"   r   )r   r   r2   pathlibr   rW   tempfiler   typingr   r   r   r   r	   r
   r   	cloudpathr   r   r   enumsr   
exceptionsr   r   r0   r$   ABCr   r^   r"   r   <module>r      si    
  	   ' O O O N N   5 -Y? 	s 	x 	^SWWg./ ^r"   