MINI MINI MANI MO
3
  \                 @   sZ   d Z ddlZddlmZ ddlmZ ddddZdddZdddZdddZ	dd Z
dS )zFdistutils.file_util
Utility functions for operating on single files.
    N)DistutilsFileError)logZcopyingzhard linkingzsymbolically linking)Nhardsym   i   c          N   C   s  d}d}zvyt | d}W n4 tk
rN } ztd| |jf W Y dd}~X nX tjj|rytj| W n4 tk
r } ztd||jf W Y dd}~X nX yt |d}W n4 tk
r } ztd||jf W Y dd}~X nX xy|j|}W n6 tk
r* } ztd| |jf W Y dd}~X nX |s4P y|j	| W q tk
rx } ztd||jf W Y dd}~X qX qW W d|r|j
  |r|j
  X dS )	a5  Copy the file 'src' to 'dst'; both must be filenames.  Any error
    opening either file, reading from 'src', or writing to 'dst', raises
    DistutilsFileError.  Data is read/written in chunks of 'buffer_size'
    bytes (default 16k).  No attempt is made to handle anything apart from
    regular files.
    Nrbzcould not open '%s': %szcould not delete '%s': %swbzcould not create '%s': %szcould not read from '%s': %szcould not write to '%s': %s)openOSErrorr   strerrorospathexistsunlinkreadwriteclose)srcdstbuffer_sizeZfsrcZfdsteZbuf r   +/usr/lib64/python3.6/distutils/file_util.py_copy_file_contents   sF    	$"""*r      c             C   s  ddl m} ddlm}	m}
m}m} tjj	| s<t
d|  tjj|rd|}
tjj|tjj
| }ntjj|}
|r|| | r|dkrtjd|  |dfS yt| }W n  tk
r   td| Y nX |dkrtjj
|tjj
| kr tjd|| |
 ntjd|| | |r|dfS |d	krttjj|oBtjj| |sytj| | |dfS  tk
rp   Y nX n<|d
krtjj|otjj| |stj| | |dfS t| | |s|rtj| }|rtj|||	 ||
 f |rtj||||  |dfS )a  Copy a file 'src' to 'dst'.  If 'dst' is a directory, then 'src' is
    copied there with the same name; otherwise, it must be a filename.  (If
    the file exists, it will be ruthlessly clobbered.)  If 'preserve_mode'
    is true (the default), the file's mode (type and permission bits, or
    whatever is analogous on the current platform) is copied.  If
    'preserve_times' is true (the default), the last-modified and
    last-access times are copied as well.  If 'update' is true, 'src' will
    only be copied if 'dst' does not exist, or if 'dst' does exist but is
    older than 'src'.
    'link' allows you to make hard links (os.link) or symbolic links
    (os.symlink) instead of copying: set it to "hard" or "sym"; if it is
    None (the default), files are copied.  Don't set 'link' on systems that
    don't support it: 'copy_file()' doesn't check if hard or symbolic
    linking is available. If hardlink fails, falls back to
    _copy_file_contents().
    Under Mac OS, uses the native file copy function in macostools; on
    other systems, uses '_copy_file_contents()' to copy file contents.
    Return a tuple (dest_name, copied): 'dest_name' is the actual name of
    the output file, and 'copied' is true if the file was copied (or would
    have been copied, if 'dry_run' true).
    r   )newer)ST_ATIMEST_MTIMEST_MODES_IMODEz4can't copy '%s': doesn't exist or not a regular filer   z"not copying %s (output up-to-date)z&invalid value '%s' for 'link' argumentz%s %s -> %sr   r   )Zdistutils.dep_utilr   statr   r   r   r   r   r
   isfiler   isdirjoinbasenamedirnamer   debug_copy_actionKeyError
ValueErrorinfor   samefilelinkr
   symlinkr   utimechmod)r   r   Z
preserve_modeZpreserve_timesupdater,   verbosedry_runr   r   r   r   r   diractionstr   r   r   	copy_fileC   sT    !
r6   c          (   C   s  ddl m}m}m}m}m} ddl}	|dkr:tjd| | |rB|S || sVt	d|  ||rrt
jj||| }n||rt	d| |f |||st	d| |f d	}
yt
j
| | W nP tk
r
 } z2|j\}}
||	jkrd
}
nt	d| ||
f W Y dd}~X nX |
rt| ||d yt
j|  W nh tk
r } zJ|j\}}
yt
j| W n tk
rp   Y nX t	d
| || |
f W Y dd}~X nX |S )a%  Move a file 'src' to 'dst'.  If 'dst' is a directory, the file will
    be moved into it with the same name; otherwise, 'src' is just renamed
    to 'dst'.  Return the new full name of the file.
    Handles cross-device moves on Unix using 'copy_file()'.  What about
    other systems???
    r   )r   r!   r"