From d4b8f3b47bcb879f8cb9c9d80d5ed0cb5ccf368f Mon Sep 17 00:00:00 2001
From: Amandine PERRIN <amandine.perrin@pasteur.fr>
Date: Wed, 10 Feb 2021 11:21:16 +0100
Subject: [PATCH] Raise error if duplication in parameters in config file

---
 PanACoTA/utils_argparse.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PanACoTA/utils_argparse.py b/PanACoTA/utils_argparse.py
index 27b816af..363cf317 100644
--- a/PanACoTA/utils_argparse.py
+++ b/PanACoTA/utils_argparse.py
@@ -196,11 +196,15 @@ class Conf_all_parser(configparser.ConfigParser):
     """
     def __init__(self, conffile, readsec=[]):
         super().__init__()
-        if not os.path.isfile(conffile):
+        if conffile != "" and not os.path.isfile(conffile):
             print(f"Error: config file {conffile} not found.")
             sys.exit(1)
         self.conffile = conffile
-        self.read(conffile)
+        try:
+            self.read(conffile)
+        except configparser.DuplicateOptionError as err:
+            print(err)
+            sys.exit(1)
         self.sec_dicts = {}
         for sec in readsec:
             # If section in configfile, put its arguments and values to a dict
-- 
GitLab