From: Olivier Sallou <osallou@debian.org>
Date: Wed, 27 Mar 2019 08:03:04 +0000
Subject: do not create dir if it exists

Bug-Debian: https://bugs.debian.org/925568
Forwarded: no
Last-Updated: 2025-02-06

command tries to create an output dir during tests, even if it
already exists, raising an error. Skip creation if already present
---
 cnvlib/commands.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cnvlib/commands.py b/cnvlib/commands.py
index 2dba8dc..97ec33e 100644
--- a/cnvlib/commands.py
+++ b/cnvlib/commands.py
@@ -2323,8 +2323,9 @@ def _cmd_import_picard(args):
         )
         if args.output_dir:
             if not os.path.isdir(args.output_dir):
-                os.mkdir(args.output_dir)
-                logging.info("Created directory %s", args.output_dir)
+                if not os.path.exists(args.output_dir):
+                    os.mkdir(args.output_dir)
+                    logging.info("Created directory %s", args.output_dir)
             outfname = os.path.join(args.output_dir, outfname)
         tabio.write(garr, outfname)
 
