From c64719229fbdfeb63c4c59749b006aded6ba00ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Wed, 13 Sep 2023 13:43:42 +0200
Subject: [PATCH] ENH: stop if old config files are used

---
 src/linkahead/configuration.py | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/linkahead/configuration.py b/src/linkahead/configuration.py
index d5ec4141..75e36d9b 100644
--- a/src/linkahead/configuration.py
+++ b/src/linkahead/configuration.py
@@ -23,8 +23,10 @@
 #
 
 import os
-import yaml
 import warnings
+
+import yaml
+
 try:
     optional_jsonschema_validate = None
     from jsonschema import validate as optional_jsonschema_validate
@@ -32,9 +34,8 @@ except ImportError:
     pass
 
 from configparser import ConfigParser
-
 from os import environ, getcwd
-from os.path import expanduser, join, isfile
+from os.path import expanduser, isfile, join
 
 
 def _reset_config():
@@ -108,6 +109,20 @@ def _read_config_files():
 
     """
     return_var = []
+    if "PYCAOSDBINI" in environ:
+        raise RuntimeError("You have set the old PYCAOSDBINI environment variable. Please use the "
+                           "new PYLINKAHEADINI variable instead and unset the old one.")
+    if os.path.exists(expanduser('~/.pycaosdb.ini')):
+        raise RuntimeError("You have a config file with the old naming scheme (pycaosdb.ini). "
+                           f"Please use the new version and rename\n"
+                           f"{expanduser('~/.pycaosdb.ini')}\n"
+                           f"to\n{expanduser('~/.pylinkahead.ini')}")
+    if os.path.exists(join(getcwd(), "pycaosdb.ini")):
+        raise RuntimeError("You have a config file with the old naming scheme (pycaosdb.ini). "
+                           f"Please use the new version and rename\n"
+                           f"{join(getcwd(), 'pycaosdb.ini')}\n"
+                           f"to\n{join(getcwd(), 'pylinkahead.ini')}")
+
     if "PYLINKAHEADINI" in environ:
         return_var.extend(configure(expanduser(environ["PYLINKAHEADINI"])))
     else:
-- 
GitLab