From eb8674c5ea5b4f30e71a656a2052d5fe851b1b07 Mon Sep 17 00:00:00 2001
From: Michael McWilliam <mimc@dtu.dk>
Date: Tue, 13 Aug 2019 16:10:24 +0200
Subject: [PATCH] Updated the logic on accompanying files

---
 wetb/hawc2/hawc2_simulation.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wetb/hawc2/hawc2_simulation.py b/wetb/hawc2/hawc2_simulation.py
index 02a583d..84b2428 100644
--- a/wetb/hawc2/hawc2_simulation.py
+++ b/wetb/hawc2/hawc2_simulation.py
@@ -192,11 +192,11 @@ class Hawc2_Simulation(object):
         if not self.accompanying_files is None:
             for i, accompanying_file in enumerate(self.accompanying_files):
                 destination = os.path.join(self.write_directory,self.accompanying_destinations[i])
-                destination = os.path.abspath(os.path.realpath(destination))
-                if not os.path.isfile(destination) and not os.path.isdir(destination):
+                if not os.path.isfile(destination) and not os.path.isdir(destination) and not os.path.islink(destination):
                     dest_dir = os.path.dirname(destination)
                     if not os.path.isdir(dest_dir):
                         os.makedirs(dest_dir)
+                    destination = os.path.abspath(os.path.realpath(destination))
                     os.symlink(accompanying_file, destination)
 
         # Get the directory
-- 
GitLab