o
    Q `                     @   s   d Z ddlmZ ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ej
r5dd	lmZ dd
lmZmZ dddZdd Z	dddZdS )z0Functions for moving files between filesystems.
    )print_function)unicode_literalsN   )copy_dir)	copy_file	manage_fs)FS)TextUnionc                 C   s   t | d|d|d dS )aJ  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.

    /workersN)move_dir)src_fsdst_fsr    r   )/usr/lib/python3/dist-packages/fs/move.pymove_fs   s   r   c                 C   s   t | h}t |ddI}||u r|j||dd n4| ( |  t|||| || 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 )a4  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``.

    TZcreate)Z	overwriteN)r   movelockr   remove)r   src_pathr   dst_path_src_fs_dst_fsr   r   r   	move_file    s   
 "r   c           	         s   fdd} fdd}| a}| E}|  1 |   |j|dd t| ||d || W d   n1 s=w   Y  W d   n1 sLw   Y  W d   n1 s[w   Y  W d   dS W d   dS 1 ssw   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.

    c                         t  ddS )NF)Z	writeabler   r   )r   r   r   srcP      zmove_dir.<locals>.srcc                      r   )NTr   r   r   )r   r   r   dstS   r    zmove_dir.<locals>.dstT)Zrecreater   N)r   Zmakedirr   Z
removetree)	r   r   r   r   r   r   r!   r   r   r   )r   r   r   r   <   s    Pr   )r   )__doc__Z
__future__r   r   typingcopyr   r   Zopenerr   ZTYPE_CHECKINGbaser	   r
   r   r   r   r   r   r   r   r   <module>   s    
!