1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 # config.py - configuration settings and global variables for Arvados clients
7 # Arvados configuration settings are taken from $HOME/.config/arvados.
8 # Environment variables override settings in the config file.
22 default_config_file = ''
23 """.. WARNING: Deprecated
24 Default configuration initialization now searches for the "default"
25 configuration in several places. This value no longer has any effect.
28 KEEP_BLOCK_SIZE = 2**26
29 EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
35 Callable[[str], Iterable[os.PathLike]],
36 ]=util._BaseDirectories('CONFIG').search,
41 if callable(config_file):
42 search_paths = iter(config_file('settings.conf'))
43 config_file = next(search_paths, '')
45 # load the specified config file if available
47 _settings = load(config_file)
51 # override any settings with environment vars
52 for var in os.environ:
53 if var.startswith('ARVADOS_'):
54 _settings[var] = os.environ[var]
56 def load(config_file):
58 with open(config_file, "r") as f:
60 if re.match(r'^\s*(?:#|$)', config_line):
62 var, val = config_line.rstrip().split('=', 2)
66 def flag_is_true(key, d=None):
69 return d.get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes'])
71 def get(key, default_val=None):
72 return settings().get(key, default_val)