Mini Shell
�
�[�i� � �d � d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZ G d� d� � ZdS )� )�print_function)�division)�absolute_importNc �\ � e Zd Zdddej ddfd�Zd� Zd� Zd� Zd� Z d � Z
d
� Zd� Zd� Z
d
S )�
CopyDirectory�*r Fc � � || _ || _ || _ || _ || _ g | _ g | _ || _ || _ || _ dS )ze
ATTENTION: values other than '*' for parameter 'directorypattern' are not supported
N)
�sourcedirectory�destinationdirectory�pattern�directorypattern�overwriteolder�
directorylist�filelist�copyfile�copy_file_mode�rewrite_plugin_conf) �self�source�destinationr r
r r r r s �copy_directory.py�__init__zCopyDirectory.__init__ sW � �
&���$/��!���� 0���,��������
� ��
�,���#6�� � � � c �� � t d� | j � � � � | � � � t d� � | � � � d S )NzGathering file list for {}z)Building directory tree and copying files)�print�formatr �walk�go)r s r �processzCopyDirectory.process# sO � �
�*�1�1�$�2K�L�L�M�M�M�� � ����
�9�:�:�:���� � � � � r c �z � t j | j � � D ] \ }}}| � | |||z � � �!dS )zB
Gather the list of directories and files to copy
N)�osr r
�_copydir)r �dir�subdirs�filess r r zCopyDirectory.walk) sN � � $&�7�4�+?�#@�#@� 6� 6��C��%��M�M�$��W�u�_�5�5�5�5� 6� 6r c � � | j D ]}| � |� � �t d� � | j D ]�\ }} t j � |� � }t j � |� � st j |� � | � ||� � | j
rt j ||� � ��# t $ r;}t d� |� � � � t |� � Y d}~��d}~ww xY wdS )z�
Perform the primary function of copying a directory
given an already constructed directory and file list
(generally created by walk)
zCopy/update files...zWarning! Can not update fle: {}N)r �
copydirectoryr r r! �path�dirname�exists�makedirsr r �shutil�copymode� Exceptionr )r � directoryr r �filepath�es r r zCopyDirectory.go0 s � � �+� *� *�I����y�)�)�)�)�
�$�%�%�%�#'�=� � ��F�K�
��7�?�?�;�7�7���w�~�~�h�/�/� *��K��)�)�)��
�
�f�k�2�2�2��&� 9��O�F�K�8�8�8����
�
�
��7�>�>�{�K�K�L�L�L��a�������������
���� � s �BC�
D�1D�Dc �
� | � ||� � }| � ||� � | � |� � }|D �]=}t j � ||� � }t j � ||� � }|� d� � r't j � |� � r| j s�| j r�t j � |� � r|t j
|� � t j t j
|� � t j k r| j �
||f� � ��
t d|z � � ��!| j �
||f� � ��?dS )z<
Perform copying for a particular directory
zplugin.confzskip %s (source not newer)N)�_files�_subdirectories�_directorysetupr! r( �join�endswithr* r r �stat�ST_MTIMEr �appendr ) r �argr/ r% �workingfilesr �filer r s r r"