Skip to content

Commit

Permalink
Fixing periods in config vars
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbyt3r committed Apr 16, 2024
1 parent bf13627 commit 217d3fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sideboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def get_config_files(requesting_file_path, is_plugin):
absolute_config_files.append(root_dir / path)
return absolute_config_files

def normalize_name(name):
return name.replace(".", "_")

def load_section_from_environment(path, section):
"""
Looks for configuration in environment variables.
Expand All @@ -109,7 +112,7 @@ def load_section_from_environment(path, section):
if setting == "__many__":
prefix = f"{path}_"
for envvar in os.environ:
if envvar.startswith(prefix):
if envvar.startswith(prefix) and not envvar.split(prefix, 1)[1] in [normalize_name(x) for x in section]:
config[envvar.split(prefix, 1)[1]] = os.environ[envvar]
else:
if isinstance(section[setting], configobj.Section):
Expand All @@ -118,9 +121,9 @@ def load_section_from_environment(path, section):
if child:
config[setting] = child
else:
name = f"{path}_{setting}"
name = normalize_name(f"{path}_{setting}")
if name in os.environ:
config[setting] = os.environ.get(name)
config[setting] = os.environ.get(normalize_name(name))
return config

def parse_config(requesting_file_path, is_plugin=True):
Expand Down

0 comments on commit 217d3fb

Please sign in to comment.