From 1d1a25a08bdb027564e3be61960b69aeca3fcc9e Mon Sep 17 00:00:00 2001
From: Daniel van der Schuur <schuur@astron.nl>
Date: Thu, 2 Jul 2015 12:19:31 +0000
Subject: [PATCH] -Now using copy_tree from distutils module instead of
 copytree from shutil  module. The difference is that now the target directory
 is recreated only  if it does not exist (previously: always recreated which
 caused only the  last copy_files entry in hdllib.cfg to have effect).

---
 tools/oneclick/base/hdl_config.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py
index 044516c464..f2030e3f30 100644
--- a/tools/oneclick/base/hdl_config.py
+++ b/tools/oneclick/base/hdl_config.py
@@ -53,6 +53,7 @@ import sys
 import os
 import os.path
 import shutil
+from distutils.dir_util import copy_tree
 import argparse
 
 class HdlConfig:
@@ -313,16 +314,9 @@ class HdlConfig:
                     sourcePathName = cm.expand_file_path_name(fpn_io[0], lib_path)
                     destinationPath = cm.expand_file_path_name(fpn_io[1], build_dir_path)
                     if os.path.isfile(sourcePathName):
-                        shutil.copy(sourcePathName, destinationPath)           # copy file
+                        shutil.copy(sourcePathName, destinationPath)     # copy file
                     else:
-                        if os.path.exists(destinationPath):
-                            if build_dir_path in destinationPath:
-                                # Only automatically remove the destinationPath if it is in the build_dir_path to avoid accidentally removing an important directory
-                                shutil.rmtree(destinationPath)
-                            else:
-                                # If the destination directory is outside the build_dir_path then require that it does not already exist
-                                sys.exit('Error : First manually remove destination directory %s' % destinationPath)
-                        shutil.copytree(sourcePathName, destinationPath)       # copy directory tree (will create new destinationPath directory)
+                        copy_tree(sourcePathName, destinationPath)       # copy directory tree (will create new destinationPath directory)
 
     
 if __name__ == '__main__':
-- 
GitLab