o
    pf0                     @   s   d Z ddlmZmZ ddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ejrEddlmZmZ ddlmZ 		dddZ		dddZ		dddZdS )z0Functions for moving files between filesystems.
    )print_functionunicode_literalsN   )
commonpath)copy_dir	copy_file)FSError)	manage_fs)OSFS)frombase)TextUnion)FSFc                 C   s   t | d|d||d dS )a  Move the contents of a filesystem to another filesystem.

    Arguments:
        src_fs (FS or str): Source filesystem (instance or URL).
        dst_fs (FS or str): Destination filesystem (instance or URL).
        workers (int): Use `worker` threads to copy data, or ``0`` (default) for
            a single-threaded copy.
        preserve_time (bool): If `True`, try to preserve mtime of the
            resources (defaults to `False`).

    /workerspreserve_timeN)move_dir)src_fsdst_fsr   r    r   @/home/ertert/spirit/venv/lib/python3.10/site-packages/fs/move.pymove_fs   s   r   Tc                 C   sp  t | dd&}t |ddd}||u r-|j||d|d 	 W d   W d   dS ||r||rz}||}||}	t||	g}
|
rt|
|}t|
|	}| S | ? t|
+}|j|||d 	 W d   W d   W d   W W d   W d   dS 1 sw   Y  W d   n1 sw   Y  W d   n1 sw   Y  W n	 ty   Y nw | B | . t	|||||d z|
| W n ty } z	|r|
| |d}~ww W d   n1 sw   Y  W d   n	1 sw   Y  W d   n1 sw   Y  W d   dS W d   dS 1 s1w   Y  dS )aR  Move a file from one filesystem to another.

    Arguments:
        src_fs (FS or str): Source filesystem (instance or URL).
        src_path (str): Path to a file on ``src_fs``.
        dst_fs (FS or str): Destination filesystem (instance or URL).
        dst_path (str): Path to a file on ``dst_fs``.
        preserve_time (bool): If `True`, try to preserve mtime of the
            resources (defaults to `False`).
        cleanup_dst_on_error (bool): If `True`, tries to delete the file copied to
            ``dst_fs`` if deleting the file from ``src_fs`` fails (defaults to `True`).

    T	writeabler   create)	overwriter   N)r   )r	   move
hassyspath
getsyspathr   r   lockr
   
ValueErrorr   remover   )r   src_pathr   dst_pathr   cleanup_dst_on_error_src_fs_dst_fssrc_syspathdst_syspathcommonrel_srcrel_dstbaseer   r   r   	move_file*   st   	




 
  $r0   c                 C   s   t | ddf}t |dddF}| 2 |  |j|dd t| |||||d || W d   n1 s9w   Y  W d   n1 sHw   Y  W d   n1 sWw   Y  W d   dS W d   dS 1 sow   Y  dS )a,  Move a directory from one filesystem to another.

    Arguments:
        src_fs (FS or str): Source filesystem (instance or URL).
        src_path (str): Path to a directory on ``src_fs``
        dst_fs (FS or str): Destination filesystem (instance or URL).
        dst_path (str): Path to a directory on ``dst_fs``.
        workers (int): Use ``worker`` threads to copy data, or ``0``
            (default) for a single-threaded copy.
        preserve_time (bool): If `True`, try to preserve mtime of the
            resources (defaults to `False`).

    Tr   r   )recreater   N)r	   r!   makedirr   
removetree)r   r$   r   r%   r   r   r'   r(   r   r   r   r   o   s*    "r   )r   F)FT)__doc__
__future__r   r   typing_pathcompatr   copyr   r   errorsr   openerr	   osfsr
   pathr   TYPE_CHECKINGr   r   r.   r   r   r0   r   r   r   r   r   <module>   s*    

J