From 84e5482a6d99fe133ab3b663b74fcc7826ea2321 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 2 Mar 2023 01:01:52 +0100 Subject: [PATCH] improve config filename error handling Signed-off-by: Csaba Kiraly --- study.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/study.py b/study.py index 20c1475..52433c5 100644 --- a/study.py +++ b/study.py @@ -10,7 +10,16 @@ def study(): print("You need to pass a configuration file in parameter") exit(1) - config = importlib.import_module(sys.argv[1]) + try: + config = importlib.import_module(sys.argv[1]) + except ModuleNotFoundError as e: + try: + config = importlib.import_module(str(sys.argv[1]).replace(".py", "")) + except ModuleNotFoundError as e: + print(e) + print("You need to pass a configuration file in parameter") + exit(1) + shape = Shape(0, 0, 0, 0, 0, 0) sim = Simulator(shape, config) sim.initLogger()