Skip to content

Commit

Permalink
Deprecating support for multiple config file as they were unused to d…
Browse files Browse the repository at this point in the history
…ate.
  • Loading branch information
chaplin89 committed Oct 6, 2024
1 parent 70b998c commit 65a5e7c
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions helix/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class HelixDefaults:

HELIX_FOLDER = Path(__file__).parents[1]
LOCAL_FOLDER = Path(Path.home(), ".helix")
LOCAL_CONFIG = Path(HELIX_FOLDER, "configuration", "main.ini")
GLOBAL_CONFIG = Path(Path.home(), ".helix", "main.ini")


Expand Down Expand Up @@ -150,11 +149,8 @@ def __init__(self) -> None:

def load(self) -> None:
self._parser = configparser.ConfigParser(interpolation=None)
if HelixDefaults.LOCAL_CONFIG.exists():
logging.info(f"Loading {HelixDefaults.LOCAL_CONFIG}")
if HelixDefaults.GLOBAL_CONFIG.exists():
logging.info(f"Loading {HelixDefaults.GLOBAL_CONFIG}")
self._parser.read(HelixDefaults.LOCAL_CONFIG)
self._parser.read(HelixDefaults.GLOBAL_CONFIG)

for var_name, var_value in ConfigurationManager.__dict__.items():
Expand Down Expand Up @@ -195,16 +191,10 @@ def save(self, save_defaults=False):
self._parser[section][key] = str(value)
if len(self._parser[section]) == 0 and not save_defaults:
self._parser.remove_section(section)
ordered_config_paths = [HelixDefaults.GLOBAL_CONFIG, HelixDefaults.LOCAL_CONFIG]
if not any([x.exists() for x in ordered_config_paths]):
with ordered_config_paths[1].open("wt") as f:
pass
for config in ordered_config_paths:
if not config.exists():
continue
with config.open("wt") as f:
self._parser.write(f)
break
if not HelixDefaults.GLOBAL_CONFIG.exists():
return
with HelixDefaults.GLOBAL_CONFIG.open("wt") as f:
self._parser.write(f)


MANAGER_CFG = None
Expand Down

0 comments on commit 65a5e7c

Please sign in to comment.