Skip to content

Commit

Permalink
[_584] allow loading settings from environemt even without use of con…
Browse files Browse the repository at this point in the history
…fig file
  • Loading branch information
d-w-moore committed Jul 12, 2024
1 parent e061922 commit 8f72382
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions irods/client_configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,30 @@ def _existing_config(path):
_load_config_line(root, match.group('key'), match.group('value'))

if use_environment_variables:
for key, variable in _calculate_overriding_environment_variables().items():
value = os.environ.get(variable)
if value is not None:
_load_config_line(root, key, value)
_load_settings_from_environment(root)

finally:
if _file:
_file.close()


default_config_dict = {}

def _load_settings_from_environment(root = None):
if root is None:
root = sys.modules[__name__]
for key, variable in _calculate_overriding_environment_variables().items():
value = os.environ.get(variable)
if value is not None:
_load_config_line(root, key, value)

def preserve_defaults():
default_config_dict.update((k,copy.deepcopy(v)) for k,v in globals().items() if isinstance(v,iRODSConfiguration))

def autoload(_file_to_load):
if _file_to_load is not None:
if _file_to_load is None:
_load_settings_from_environment()
else:
load(file = _file_to_load, use_environment_variables = True)

def new_default_config():
Expand Down

0 comments on commit 8f72382

Please sign in to comment.