Skip to content

Commit

Permalink
Make config_path() public
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jul 7, 2024
1 parent 3ff2ed3 commit f011387
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/anemoi/utils/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import json

from ..config import _config_path
from ..config import config_path
from ..config import load_config
from . import Command

Expand All @@ -23,7 +23,7 @@ def add_arguments(self, command_parser):

def run(self, args):
if args.path:
print(_config_path())
print(config_path())
else:
print(json.dumps(load_config(), indent=4))

Expand Down
12 changes: 6 additions & 6 deletions src/anemoi/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _set_defaults(a, b):
a.setdefault(k, v)


def _config_path(name="settings.toml"):
def config_path(name="settings.toml"):
global QUIET

if name.startswith("/") or name.startswith("."):
Expand Down Expand Up @@ -208,7 +208,7 @@ def _load_config(name="settings.toml", secrets=None, defaults=None):
if name in CONFIG:
return CONFIG[name]

path = _config_path(name)
path = config_path(name)
if os.path.exists(path):
config = load_any_dict_format(path)
else:
Expand Down Expand Up @@ -245,7 +245,7 @@ def _load_config(name="settings.toml", secrets=None, defaults=None):
def _save_config(name, data):
CONFIG.pop(name, None)

conf = _config_path(name)
conf = config_path(name)

if conf.endswith(".json"):
with open(conf, "w") as f:
Expand Down Expand Up @@ -300,7 +300,7 @@ def load_config(name="settings.toml", secrets=None, defaults=None):

def load_raw_config(name, default=None):

path = _config_path(name)
path = config_path(name)
if os.path.exists(path):
return load_any_dict_format(path)

Expand All @@ -324,13 +324,13 @@ def check_config_mode(name="settings.toml", secrets_name=None, secrets=None):
if name in CHECKED:
return

conf = _config_path(name)
conf = config_path(name)
if not os.path.exists(conf):
return
mode = os.stat(conf).st_mode
if mode & 0o777 != 0o600:
if secrets_name:
secret_path = _config_path(secrets_name)
secret_path = config_path(secrets_name)
raise SystemError(
f"Configuration file {conf} should not hold entries {secrets}.\n"
f"Please move them to {secret_path}."
Expand Down

0 comments on commit f011387

Please sign in to comment.