Ë
    ¸­ h¸  ã                  ó  — d dl m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 d dlmZ dd„Zdd	„Zdd
„Zddœdd„Zdddddœ	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zd d„Zd d„Zd!d„Zddddœ	 	 	 	 	 	 	 	 	 d"d„Zy)#é    )ÚannotationsN)ÚCallable)Úurlsplit)Úget_path)Ú
assert_dirÚexists)ÚPathInc                ó„   — t        | «      } t        | «      j                  }t        j                  j	                  |«      }|S )z3
    Get the filename from the given path/url.
    )Ú	_get_pathr   ÚpathÚosÚbasename)r   ÚfilepathÚfilenames      úJ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fsutil/paths.pyÚget_filenamer      s5   € ô �T‹?€DÜ˜‹~×"Ñ"€HÜ�w‰w×Ñ Ó)€HØ€Oó    c                ó8   — t        | «      } t        | «      \  }}|S )z8
    Get the file basename from the given path/url.
    ©r   Úsplit_filename)r   r   Ú_s      r   Úget_file_basenamer      s    € ô �T‹?€DÜ  Ó&�K€HˆaØ€Or   c                ó8   — t        | «      } t        | «      \  }}|S )z9
    Get the file extension from the given path/url.
    r   )r   r   Ú	extensions      r   Úget_file_extensionr       s!   € ô �T‹?€DÜ! $Ó'�L€A€yØÐr   é   )Úlevelsc               óh   — t        | «      } t        | gt        j                  gt	        d|«      z  ¢­Ž S )zH
    Get the parent directory for the given path going up N levels.
    r   )r   Ú	join_pathr   ÚpardirÚmax)r   r   s     r   Úget_parent_dirr"   )   s.   € ô �T‹?€DÜ�TÐ;œbŸi™i˜[¬3¨q°&«>Ñ9Ò;Ð;r   Ú ú-)ÚprefixÚsuffixr   Ú	separatorc               ó  — t        | «      } t        | «       d}	 |r	||› |› �z  }t        j                  «       }||› z  }|r	||› |› �z  }|r'|j	                  d«      j                  «       }|d|› �z  }t        t        | |«      «      rŒp	 |S )zM
    Get a unique name for a directory/file at the given directory path.
    r#   ú.)r   r   ÚuuidÚuuid4ÚlstripÚlowerr   r   )r   r%   r&   r   r'   ÚnameÚuids          r   Úget_unique_namer0   1   s¦   € ô �T‹?€DÜˆtÔØ€DØ
ÙØ�v�h˜y˜kÐ*Ñ*ˆDÜ�j‰j‹lˆØ�3�%ÑˆÙØ�y�k & Ð*Ñ*ˆDÙØ!×(Ñ(¨Ó-×3Ñ3Ó5ˆIØ�a˜	�{�OÑ#ˆDÜ”)˜D $Ó'Ô(ØØØ€Kr   c                ó¦   — | j                  d«      j                  «       } |j                  dd«      j                  «       }| r|r	| › d|› �}|S | xs |S )zH
    Create a filename joining the file basename and the extension.
    r)   r#   )ÚrstripÚstripÚreplace)r   r   r   s      r   Újoin_filenamer5   O   s[   € ð �‰˜sÓ#×)Ñ)Ó+€HØ×!Ñ! # rÓ*×0Ñ0Ó2€IÙ‘IØ�Z˜q  Ð,ˆØˆØÒ �yÐ r   c                ó0   — t        | «      } t        | |«      S )zH
    Create a filepath joining the directory path and the filename.
    )r   r   )Údirpathr   s     r   Újoin_filepathr8   [   s   € ô ˜Ó €GÜ�W˜hÓ'Ð'r   c                ó€  — t        | «      } | }t        | «      dv r<t        j                  j	                  t        j                  j                  | «      «      }|D � cg c]  } t        | «      j                  d«      ‘Œ }} t        j                  j                  t        j                  j                  |g|¢­Ž «      S c c} w )z¸
    Create a path joining path and paths.
    If path is __file__ (or a .py file), the resulting path will be relative
    to the directory path of the module in which it's used.
    )ÚpyÚpycÚpyoz/\)	r   r   r   r   ÚdirnameÚrealpathr,   ÚnormpathÚjoin)r   ÚpathsÚbasepathÚ	paths_strs       r   r   r   c   s�   € ô �T‹?€DØ€HÜ˜$ÓÐ#7Ñ7Ü—7‘7—?‘?¤2§7¡7×#3Ñ#3°DÓ#9Ó:ˆØ;@ÖA°4”˜4“×'Ñ'¨Õ.ÐA€IÐAÜ�7‰7×ÑœBŸG™GŸL™L¨Ð>°IÒ>Ó?Ð?ùò Bs   Á!B;c                óº   — t        | «      } t        | «      }t        j                  j	                  |«      \  }}|j                  dd«      j                  «       }||fS )zB
    Split a filename and returns its basename and extension.
    r)   r#   )r   r   r   r   Úsplitextr4   r3   )r   r   r   r   s       r   r   r   q   sV   € ô �T‹?€DÜ˜DÓ!€HÜŸ'™'×*Ñ*¨8Ó4Ñ€HˆiØ×!Ñ! # rÓ*×0Ñ0Ó2€IØ�iÐ Ð r   c                ót   — t        | «      } t        j                  j                  | «      }t	        | «      }||fS )zG
    Split a filepath and returns its directory-path and filename.
    )r   r   r   r=   r   )r   r7   r   s      r   Úsplit_filepathrG   |   s4   € ô �T‹?€DÜ�g‰g�o‰o˜dÓ#€GÜ˜DÓ!€HØ�XÐÐr   c                óÐ   — t        | «      } t        j                  j                  | «      \  }}|j                  t        j                  «      |gz   }t        t        d|«      «      }|S )z2
    Split a path and returns its path-names.
    N)r   r   r   ÚsplitÚsepÚlistÚfilter)r   ÚheadÚtailÚnamess       r   Ú
split_pathrP   †   sR   € ô �T‹?€DÜ—‘—‘˜tÓ$�J€Dˆ$Ø�J‰J”r—v‘vÓ $ Ñ'€EÜ”˜˜eÓ$Ó%€EØ€Lr   )r7   r   r   c               ó(  — 	 	 	 	 	 	 dd„}t        |du |du |du g«      rt        d«      ‚t        | «      \  }}t        |«      \  }} |||«      }	 |||«      }
 |||«      }t	        |	|
|g«      st        d«      ‚t        |
|«      }t        |	|«      }|S )a  
    Trasform a filepath by applying the provided optional changes.

    :param path: The path.
    :type path: PathIn
    :param dirpath: The new dirpath or a callable.
    :type dirpath: str | Callable[[str], str] | None
    :param basename: The new basename or a callable.
    :type basename: str | Callable[[str], str] | None
    :param extension: The new extension or a callable.
    :type extension: str | Callable[[str], str] | None

    :returns: The filepath with the applied changes.
    :rtype: str
    c                ód   — |}| �+t        | «      r
 | |«      }|S t        | t        «      r| }|S |}|S )N)ÚcallableÚ
isinstanceÚstr)Ú	new_valueÚ	old_valueÚvalues      r   Ú
_get_valuez&transform_filepath.<locals>._get_value¨   sL   € ð ˆØÐ Ü˜	Ô"Ù! )Ó,�ð
 ˆô	 ˜I¤sÔ+Ø!�ð ˆð "�Øˆr   NzTInvalid arguments: at least one of 'dirpath', 'basename' or 'extension' is required.)rV   ú!str | Callable[[str], str] | NonerW   rU   ÚreturnrU   )ÚallÚ
ValueErrorrG   r   Úanyr5   r8   )r   r7   r   r   rY   Úold_dirpathÚold_filenameÚold_basenameÚold_extensionÚnew_dirpathÚnew_basenameÚnew_extensionÚnew_filenameÚnew_filepaths                 r   Útransform_filepathrh   ‘   sÙ   € ð.Ø4ðàðð 
óô ˆG�tˆO˜X¨Ð-¨y¸DÐ/@ÐAÔBÜð@ó
ð 	
ô !/¨tÓ 4Ñ€K�Ü"0°Ó">Ñ€L�-Ù˜W kÓ2€KÙ˜h¨Ó5€LÙ˜y¨-Ó8€MÜ�˜\¨=Ð9Ô:Üð@ó
ð 	
ô ! ¨}Ó=€LÜ  ¨lÓ;€LØÐr   )r   r	   r[   rU   )r   r	   r   Úintr[   rU   )r   r	   r%   rU   r&   rU   r   rU   r'   rU   r[   rU   )r   rU   r   rU   r[   rU   )r7   r	   r   rU   r[   rU   )r   r	   rA   r	   r[   rU   )r   r	   r[   ztuple[str, str])r   r	   r[   z	list[str])
r   r	   r7   rZ   r   rZ   r   rZ   r[   rU   )Ú
__future__r   r   r*   Úcollections.abcr   Úurllib.parser   Úfsutil.argsr   r   Úfsutil.checksr   r   Úfsutil.typesr	   r   r   r   r"   r0   r5   r8   r   r   rG   rP   rh   © r   r   ú<module>rq      sâ   ðÝ "ã 	Û Ý $Ý !å -ß ,Ý óóóð 34õ <ð ØØØñØ
ðð ðð ð	ð
 ðð ðð 	óó<	!ó(ó@ó!óóð 26Ø26Ø37ñ6Ø
ð6ð /ð6ð 0ð	6ð
 1ð6ð 	ô6r   