1 # config.py - configuration settings and global variables for Arvados clients
3 # Arvados configuration settings are taken from $HOME/.config/arvados.
4 # Environment variables override settings in the config file.
10 if os.environ.get('HOME') is not None:
11 default_config_file = os.environ['HOME'] + '/.config/arvados/settings.conf'
13 default_config_file = ''
15 EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
17 def initialize(config_file=default_config_file):
21 # load the specified config file if available
23 _settings = load(config_file)
27 # override any settings with environment vars
28 for var in os.environ:
29 if var.startswith('ARVADOS_'):
30 _settings[var] = os.environ[var]
32 def load(config_file):
34 with open(config_file, "r") as f:
36 if re.match('^\s*$', config_line):
38 if re.match('^\s*#', config_line):
40 var, val = config_line.rstrip().split('=', 2)
44 def flag_is_true(key):
45 return get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes'])
47 def get(key, default_val=None):
48 return settings().get(key, default_val)