Ë
    ¸­ h‚;  ã                  óª  — d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% d d	l&m'Z' d5d
„Z(d5d„Z)dddœd6d„Z*ddœ	 	 	 	 	 	 	 	 	 d7d„Z+d8d„Z,ddœ	 	 	 	 	 	 	 	 	 d7d„Z-ddœd9d„Z.d:ddœd;d„Z/d<d„Z0d5d„Z1d=d„Z2d<d„Z3d=d„Z4ddddœ	 	 	 	 	 	 	 	 	 	 	 d>d„Z5ddœ	 	 	 	 	 	 	 d?d„Z6d@d „Z7d@d!„Z8d5d"„Z9d5d#„Z:ddœ	 	 	 	 	 	 	 	 	 d7d$„Z;ddœ	 	 	 	 	 	 	 	 	 d7d%„Z<dAd&„Z=d5d'„Z>d=d(„Z?d<d)„Z@d=d*„ZAdBd+„ZBdBd,„ZCdCd-„ZDdDd.„ZEdd/œdEd0„ZFdd/œdEd1„ZGdFd2„ZHdGdFd3„ZIdHdFd4„ZJy)Ié    )ÚannotationsN)ÚCallable)ÚAny)Úget_path)
Ú
assert_dirÚassert_fileÚassert_not_dirÚassert_not_existsÚassert_not_fileÚexistsÚis_dirÚis_empty_dirÚis_empty_fileÚis_file)Úrequire_requests)	Úget_file_basenameÚget_file_extensionÚget_filenameÚget_unique_nameÚjoin_filenameÚjoin_filepathÚ	join_pathÚsplit_filenameÚsplit_filepath)ÚPathInc                óÖ   — t        | «      } t        j                  | d¬«      D ]D  \  }}}|D ]9  }t        j                  j	                  ||«      }t        |«      sŒ/t        |«       Œ; ŒF y ©NF)Útopdown)Ú	_get_pathÚosÚwalkÚpathÚjoinr   Ú
remove_dir)r"   ÚbasepathÚdirnamesÚ_ÚdirnameÚdirpaths         úO/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fsutil/operations.pyÚ_clean_dir_empty_dirsr+   (   s_   € Ü�T‹?€DÜ!#§¡¨°uÔ!=ò $Ñˆ�(˜AØò 	$ˆGÜ—g‘g—l‘l 8¨WÓ5ˆGÜ˜GÕ$Ü˜7Õ#ñ	$ñ$ó    c                óÖ   — t        | «      } t        j                  | d¬«      D ]D  \  }}}|D ]9  }t        j                  j	                  ||«      }t        |«      sŒ/t        |«       Œ; ŒF y r   )r   r    r!   r"   r#   r   Úremove_file)r"   r%   r'   Ú	filenamesÚfilenameÚfilepaths         r*   Ú_clean_dir_empty_filesr2   1   s_   € Ü�T‹?€DÜ"$§'¡'¨$¸Ô">ò &Ñˆ�!�YØ!ò 	&ˆHÜ—w‘w—|‘| H¨hÓ7ˆHÜ˜XÕ&Ü˜HÕ%ñ	&ñ&r,   T)ÚdirsÚfilesc               óf   — t        | «      } t        | «       |rt        | «       |rt        | «       yy)zM
    Clean a directory by removing empty directories and/or empty files.
    N)r   r   r2   r+   )r"   r3   r4   s      r*   Ú	clean_dirr6   :   s0   € ô �T‹?€DÜˆtÔÙÜ˜tÔ$ÙÜ˜dÕ#ð r,   F)Ú	overwritec               óH  — t        | «      } t        |«      }t        | «       t        j                  j	                  t        j                  j                  | «      «      }t        j                  j                  ||«      }t        |«       |st        |«       t        | |fi |¤Ž y)a  
    Copy the directory at the given path and all its content to dest path.
    If overwrite is not allowed and dest path exists, an OSError is raised.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.copytree
    N)
r   r   r    r"   ÚbasenameÚnormpathr#   r   r
   Úcopy_dir_content)r"   Údestr7   Úkwargsr(   s        r*   Úcopy_dirr>   F   sw   € ô �T‹?€DÜ�T‹?€DÜˆtÔÜ�g‰g×ÑœrŸw™w×/Ñ/°Ó5Ó6€GÜ�7‰7�<‰<˜˜gÓ&€DÜ�DÔÙÜ˜$ÔÜ�T˜4Ñ* 6Ó*r,   c                óÄ   — t        | «      } t        |«      }t        | «       t        |«       t        |«       |j	                  dd«       t        j                  | |fi |¤Ž y)zÈ
    Copy the content of the directory at the given path to dest path.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.copytree
    Údirs_exist_okTN)r   r   r   Ú	make_dirsÚ
setdefaultÚshutilÚcopytree)r"   r<   r=   s      r*   r;   r;   Z   sP   € ô �T‹?€DÜ�T‹?€DÜˆtÔÜ�DÔÜˆd„OØ
×Ñ�o tÔ,Ü
‡O�O�D˜$Ñ) &Ó)r,   c               óº   — t        | «      } t        |«      }t        | «       t        |«       |st        |«       t	        |«       t        j                  | |fi |¤Ž y)a  
    Copy the file at the given path and its metadata to dest path.
    If overwrite is not allowed and dest path exists, an OSError is raised.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.copy2
    N)r   r   r	   r
   Úmake_dirs_for_filerC   Úcopy2©r"   r<   r7   r=   s       r*   Ú	copy_filerI   i   sL   € ô �T‹?€DÜ�T‹?€DÜ�ÔÜ�4ÔÙÜ˜$ÔÜ�tÔÜ
‡L�L��tÑ&˜vÓ&r,   c               ó`   — t        | «      } t        | «       |st        | «       t        | «       y)zt
    Create directory at the given path.
    If overwrite is not allowed and path exists, an OSError is raised.
    N)r   r   r
   rA   )r"   r7   s     r*   Ú
create_dirrK   |   s'   € ô
 �T‹?€DÜ�DÔÙÜ˜$ÔÜˆd…Or,   c               óh   — ddl m} t        | «      } t        | «       |st	        | «        || |«       y)zŠ
    Create file with the specified content at the given path.
    If overwrite is not allowed and path exists, an OSError is raised.
    r   )Ú
write_fileN)Ú	fsutil.iorM   r   r	   r
   )r"   Úcontentr7   rM   s       r*   Úcreate_filerP   ˆ   s-   € õ
 %ä�T‹?€DÜ�4ÔÙÜ˜$ÔÙˆt�WÕr,   c                ó   — t        | «      }|S )z
    Alias for remove_dir.
    ©r$   ©r"   Úremoveds     r*   Ú
delete_dirrU   –   s   € ô ˜Ó€GØ€Nr,   c                ó   — t        | «       y)z'
    Alias for remove_dir_content.
    N)Úremove_dir_content©r"   s    r*   Údelete_dir_contentrY   ž   s   € ô �tÕr,   c                 ó   — t        | Ž  y)z 
    Alias for remove_dirs.
    N)Úremove_dirs©Úpathss    r*   Údelete_dirsr^   ¥   s   € ô �Òr,   c                ó   — t        | «      }|S )z 
    Alias for remove_file.
    ©r.   rS   s     r*   Údelete_filera   ¬   s   € ô ˜$Ó€GØ€Nr,   c                 ó   — t        | Ž  y)z!
    Alias for remove_files.
    N)Úremove_filesr\   s    r*   Údelete_filesrd   ´   s   € ô �%Òr,   i    )r)   r0   Ú
chunk_sizec               ó   — t        «       }d|d<    |j                  | fi |¤Ž5 }|j                  «        |s||j                  j                  dd«      xs d}d}t	        j
                  ||«      }	|	r|	j                  d«      }|st        | «      }|s"t        t        j                  «       «      }
d|
› �}|xs t        j                  «       }t        |«      }t        ||«      }t        |«       t!        |d«      5 }|j#                  |¬	«      D ]  }|sŒ|j%                  |«       Œ 	 d
d
d
«       d
d
d
«       |S # 1 sw Y   ŒxY w# 1 sw Y   S xY w)a!  
    Download a file from url to dirpath.
    If dirpath is not provided, the file will be downloaded to a temp directory.
    If filename is provided, the file will be named using filename.
    It is possible to pass extra request options
    (eg. for authentication) using **kwargs.
    TÚstreamzcontent-dispositionÚ zfilename="(.*)"é   z	download-Úwb)re   N)r   ÚgetÚraise_for_statusÚheadersÚreÚsearchÚgroupr   ÚstrÚuuidÚuuid4ÚtempfileÚ
gettempdirr   r   rF   ÚopenÚiter_contentÚwrite)Úurlr)   r0   re   r=   ÚrequestsÚresponseÚcontent_dispositionÚfilename_patternÚfilename_matchÚfilename_uuidr1   ÚfileÚchunks                 r*   Údownload_filer‚   »   sU  € ô  Ó!€Hð €Fˆ8ÑØ	ˆ�‰�cÑ	$˜VÑ	$ð &¨Ø×!Ñ!Ô#ñ à"*×"2Ñ"2×"6Ñ"6Ð7LÈbÓ"QÒ"WÐUWÐØ1ÐÜŸY™YÐ'7Ð9LÓMˆNÙØ)×/Ñ/°Ó2�áÜ'¨Ó,�áÜ #¤D§J¡J£LÓ 1�Ø& } oÐ6�ð Ò2œX×0Ñ0Ó2ˆÜ˜GÓ$ˆÜ˜W hÓ/ˆÜ˜8Ô$ô �(˜DÓ!ð 	& TØ!×.Ñ.¸*Ð.ÓEò &�ÚØ—J‘J˜uÕ%ñ&÷	&÷5&ð< €O÷		&ð 	&ú÷5&ð< €Oús*   £CEÃ8D7ÄD7Ä%EÄ7E 	Ä<EÅE©Ú	predicatec               ó°   — g }|D ]>  }t         j                  j                  | |«      }|�	 ||«      sŒ.|j                  |«       Œ@ |j	                  «        |S )z»
    Filter paths relative to basepath according to the optional predicate function.
    If predicate is defined, paths are filtered using it,
    otherwise all paths will be listed.
    )r    r"   r#   ÚappendÚsort)r%   Úrelpathsr„   r]   ÚrelpathÚabspaths         r*   Ú_filter_pathsr‹   ï   sU   € ð €EØò "ˆÜ—'‘'—,‘,˜x¨Ó1ˆØÐ¡	¨'Õ 2Ø�L‰L˜Õ!ð"ð 
‡J�J„LØ€Lr,   c                ób   — t        | «      } t        | t        j                  | «      t        ¬«      S )zE
    List all directories contained at the given directory path.
    rƒ   )r   r‹   r    Úlistdirr   rX   s    r*   Ú	list_dirsrŽ     s%   € ô �T‹?€DÜ˜œrŸz™z¨$Ó/¼6ÔBÐBr,   c                ób   — t        | «      } t        | t        j                  | «      t        ¬«      S )z?
    List all files contained at the given directory path.
    rƒ   )r   r‹   r    r�   r   rX   s    r*   Ú
list_filesr�     s%   € ô �T‹?€DÜ˜œrŸz™z¨$Ó/¼7ÔCÐCr,   c                óv   — t        | «      } t        | «      ryt        | «       t        j                  | d¬«       y)z’
    Create the directories needed to ensure that the given path exists.
    If a file already exists at the given path an OSError is raised.
    NT)Úexist_ok)r   r   r   r    ÚmakedirsrX   s    r*   rA   rA     s-   € ô
 �T‹?€DÜˆd„|ØÜ�DÔÜ‡K�K�˜tÖ$r,   c                ó€   — t        | «      } t        | «      ryt        | «       t        | «      \  }}|rt	        |«       yy)z—
    Create the directories needed to ensure that the given path exists.
    If a directory already exists at the given path an OSError is raised.
    N)r   r   r	   r   rA   )r"   r)   r'   s      r*   rF   rF     s=   € ô
 �T‹?€DÜˆt„}ØÜ�4ÔÜ Ó%�J€GˆQÙÜ�'Õð r,   c               óº   — t        | «      } t        |«      }t        | «       t        |«       |st        |«       t	        |«       t        j                  | |fi |¤Ž y)a   
    Move an existing dir from path to dest directory.
    If overwrite is not allowed and dest path exists, an OSError is raised.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.move
    N)r   r   r   r
   rA   rC   ÚmoverH   s       r*   Úmove_dirr—   -  sK   € ô �T‹?€DÜ�T‹?€DÜˆtÔÜ�DÔÙÜ˜$ÔÜˆd„OÜ
‡K�K��dÑ%˜fÓ%r,   c               ó"  — t        | «      } t        |«      }t        | «       t        |«       t        j                  j                  |t        | «      «      }t        |«       |st        |«       t        |«       t        j                  | |fi |¤Ž y)a  
    Move an existing file from path to dest directory.
    If overwrite is not allowed and dest path exists, an OSError is raised.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.move
    N)r   r   r   r    r"   r#   r   r	   r
   rF   rC   r–   rH   s       r*   Ú	move_filer™   @  sm   € ô �T‹?€DÜ�T‹?€DÜ�ÔÜ�DÔÜ�7‰7�<‰<˜œl¨4Ó0Ó1€DÜ�4ÔÙÜ˜$ÔÜ�tÔÜ
‡K�K��dÑ%˜fÓ%r,   c                óŠ   — t        | «      } t        | «      syt        | «       t        j                  | fi |¤Ž t        | «       S )a
  
    Remove a directory at the given path and all its content.
    If the directory is removed with success returns True, otherwise False.
    More informations about kwargs supported options here:
    https://docs.python.org/3/library/shutil.html#shutil.rmtree
    F)r   r   r   rC   Úrmtree)r"   r=   s     r*   r$   r$   U  s=   € ô �T‹?€DÜ�$Œ<ØÜˆtÔÜ
‡M�M�$Ñ!˜&Ò!Ü�d‹|ÐÐr,   c                ót   — t        | «      } t        | «       t        t        | «      Ž  t	        t        | «      Ž  y)zI
    Removes all directory content (both sub-directories and files).
    N)r   r   r[   rŽ   rc   r�   rX   s    r*   rW   rW   d  s.   € ô �T‹?€DÜˆtÔÜ”˜4“Ñ!Ü”*˜TÓ"Ò#r,   c                 ó(   — | D ]  }t        |«       Œ y)zO
    Remove multiple directories at the given paths and all their content.
    NrR   ©r]   r"   s     r*   r[   r[   n  s   € ð ò ˆÜ�4Õñr,   c                óˆ   — t        | «      } t        | «      syt        | «       t        j                  | «       t        | «       S )zq
    Remove a file at the given path.
    If the file is removed with success returns True, otherwise False.
    F)r   r   r   r    ÚremoverX   s    r*   r.   r.   v  s7   € ô
 �T‹?€DÜ�$Œ<ØÜ�ÔÜ‡I�Iˆd„OÜ�d‹|ÐÐr,   c                 ó(   — | D ]  }t        |«       Œ y)z3
    Remove multiple files at the given paths.
    Nr`   rž   s     r*   rc   rc   ƒ  s   € ð ò ˆÜ�DÕñr,   c                ó  — t        | «      } t        | «       t        t        j                  j                  | «      «      }||d<   t        j                  j                  |Ž }t        |«       t        j                  | |«       y)zˆ
    Rename a directory with the given name.
    If a directory or a file with the given name already exists, an OSError is raised.
    éÿÿÿÿN)	r   r   Úlistr    r"   Úsplitr#   r
   Úrename)r"   ÚnameÚcompsr<   s       r*   Ú
rename_dirr©   ‹  s]   € ô
 �T‹?€DÜˆtÔÜ”—‘—‘˜tÓ$Ó%€EØ€Eˆ"�IÜ�7‰7�<‰<˜Ð€DÜ�dÔÜ‡I�Iˆd�DÕr,   c                ó¦   — t        | «      } t        | «       t        | «      \  }}t        ||«      }t	        |«       t        j                  | |«       y)zƒ
    Rename a file with the given name.
    If a directory or a file with the given name already exists, an OSError is raised.
    N)r   r   r   r   r
   r    r¦   )r"   r§   r)   r'   r<   s        r*   Úrename_filer«   ™  sE   € ô
 �T‹?€DÜ�ÔÜ Ó%�J€GˆQÜ˜ $Ó'€DÜ�dÔÜ‡I�Iˆd�DÕr,   c                ó`   — t        | «      } t        | «      }t        ||«      }t        | |«       y)z9
    Rename a file basename with the given basename.
    N)r   r   r   r«   )r"   r9   Ú	extensionr0   s       r*   Úrename_file_basenamer®   ¦  s-   € ô �T‹?€DÜ" 4Ó(€IÜ˜X yÓ1€HÜ��hÕr,   c                ó`   — t        | «      } t        | «      }t        ||«      }t        | |«       y)z;
    Rename a file extension with the given extension.
    N)r   r   r   r«   )r"   r­   r9   r0   s       r*   Úrename_file_extensionr°   °  s-   € ô �T‹?€DÜ  Ó&€HÜ˜X yÓ1€HÜ��hÕr,   )Ú
autodeletec               óª  — t        | «      } t        |«      }t        | «       t        |«       | |k(  ryt        | «       t	        | «      \  }}t        |«      }t        ||«      }t        ||«       t        | «      r>t        |«      }t        ||«      }t        | |¬«       t        ||¬«       t        |¬«       nt        ||¬«       |rt        |¬«       yy)zÅ
    Replace directory at the specified path with the directory located at src.
    If autodelete, the src directory will be removed at the end of the operation.
    Optimized for large files.
    N©r"   r§   rX   )r   r   r   rA   r   r   r   r;   r   r©   r$   )r"   Úsrcr±   r)   r(   Útemp_dirnameÚ	temp_destÚ	temp_paths           r*   Úreplace_dirr¸   º  s¸   € ô �T‹?€DÜ
�C‹.€CÜ�DÔÜˆs„Oàˆs‚{Øäˆd„Oä% dÓ+Ñ€GˆWä" 7Ó+€LÜ˜' <Ó0€IÜ�S˜)Ô$äˆd„|Ü& wÓ/ˆÜ˜g |Ó4ˆ	Ü˜ <Õ0Ü˜	¨Õ0Ü˜	Ö"ä˜	¨Õ0áÜ˜Öð r,   c               óÒ  — t        | «      } t        |«      }t        | «       t        |«       | |k(  ryt        | «       t	        | «      \  }}t        |«      \  }}t        ||¬«      }t        ||«      }t        ||d¬«       t        | «      r@t        ||¬«      }t        ||«      }	t        | |¬«       t        ||¬«       t        |	¬«       nt        ||¬«       |rt        |¬«       yy)z¶
    Replace file at the specified path with the file located at src.
    If autodelete, the src file will be removed at the end of the operation.
    Optimized for large files.
    N)r­   F)r"   r<   r7   r³   rX   )r   r	   r   rF   r   r   r   r   rI   r   r«   r.   )
r"   r´   r±   r)   r0   r'   r­   Útemp_filenamer¶   r·   s
             r*   Úreplace_filer»   Ý  sÎ   € ô �T‹?€DÜ
�C‹.€CÜ�4ÔÜ�ÔØˆs‚{Øä�tÔä& tÓ,Ñ€GˆXÜ! (Ó+�L€A€yä# G°yÔA€MÜ˜' =Ó1€IÜ�3˜Y°%Õ8äˆd„|Ü'¨¸9ÔEˆÜ˜g }Ó5ˆ	Ü˜ MÕ2Ü˜¨Õ2Ü˜Ö#ä˜¨Õ2áÜ˜Öð r,   c                ó    — t        | «      } t        | «       t        j                  j	                  | |«      }t        j
                  |d¬«      }|S )zG
    Search all paths relative to path matching the given pattern.
    T)Ú	recursive)r   r   r    r"   r#   Úglob)r"   ÚpatternÚpathnamer]   s       r*   Ú_search_pathsrÁ      s>   € ô �T‹?€DÜˆtÔÜ�w‰w�|‰|˜D 'Ó*€HÜ�I‰I�h¨$Ô/€EØ€Lr,   c                óP   — t        | «      } t        | t        | |«      t        ¬«      S )zD
    Search for directories at path matching the given pattern.
    rƒ   )r   r‹   rÁ   r   ©r"   r¿   s     r*   Úsearch_dirsrÄ     s#   € ô �T‹?€DÜ˜œ}¨T°7Ó;ÄvÔNÐNr,   c                óP   — t        | «      } t        | t        | |«      t        ¬«      S )z>
    Search for files at path matching the given pattern.
    rƒ   )r   r‹   rÁ   r   rÃ   s     r*   Úsearch_filesrÆ     s#   € ô �T‹?€DÜ˜œ}¨T°7Ó;ÄwÔOÐOr,   )r"   r   ÚreturnÚNone)r"   r   r3   Úboolr4   rÉ   rÇ   rÈ   )
r"   r   r<   r   r7   rÉ   r=   r   rÇ   rÈ   )r"   r   r<   r   r=   r   rÇ   rÈ   )r"   r   r7   rÉ   rÇ   rÈ   )rh   )r"   r   rO   rq   r7   rÉ   rÇ   rÈ   )r"   r   rÇ   rÉ   )r]   r   rÇ   rÈ   )ry   rq   r)   zPathIn | Noner0   z
str | Nonere   Úintr=   r   rÇ   rq   )r%   rq   rˆ   ú	list[str]r„   zCallable[[str], bool] | NonerÇ   rË   )r"   r   rÇ   rË   )r"   r   r=   r   rÇ   rÉ   )r"   r   r§   rq   rÇ   rÈ   )r"   r   r9   rq   rÇ   rÈ   )r"   r   r­   rq   rÇ   rÈ   )r"   r   r´   r   r±   rÉ   rÇ   rÈ   )r"   r   r¿   rq   rÇ   rË   )z**/*)z**/*.*)KÚ
__future__r   r¾   r    rn   rC   rt   rr   Úcollections.abcr   Útypingr   Úfsutil.argsr   r   Úfsutil.checksr   r   r	   r
   r   r   r   r   r   r   Úfsutil.depsr   Úfsutil.pathsr   r   r   r   r   r   r   r   r   Úfsutil.typesr   r+   r2   r6   r>   r;   rI   rK   rP   rU   rY   r^   ra   rd   r‚   r‹   rŽ   r�   rA   rF   r—   r™   r$   rW   r[   r.   rc   r©   r«   r®   r°   r¸   r»   rÁ   rÄ   rÆ   © r,   r*   ú<module>rÕ      sD  ðÝ "ã Û 	Û 	Û Û Û Ý $Ý å -÷÷ ÷ õ )÷
÷ 
õ 
õ  ó$ó&ð -1Àõ 	$ð 6;ñ+Ø
ð+Øð+Ø.2ð+ØFIð+à	ó+ó(*ð  6;ñ'Ø
ð'Øð'Ø.2ð'ØFIð'à	ó'ð& 38õ 	ðÀeõ óóóóóð "ØØñ1Ø	ð1ð ð1ð ð	1ð
 ð1ð ð1ð 	ó1ðp /3ñ	Øðàðð ,ð	ð
 óó(CóDó	%óð 6;ñ&Ø
ð&Øð&Ø.2ð&ØFIð&à	ó&ð( 6;ñ&Ø
ð&Øð&Ø.2ð&ØFIð&à	ó&ó*ó$óó
óóó
ó ó ð BGõ  ðF CHõ  óFôOõPr,   