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 default_config_file = os.environ['HOME'] + '/.config/arvados/settings.conf'
12 EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
14 def initialize(config_file=default_config_file):
18 # load the specified config file if available
20 _settings = load(config_file)
24 # override any settings with environment vars
25 for var in os.environ:
26 if var.startswith('ARVADOS_'):
27 _settings[var] = os.environ[var]
29 def load(config_file):
31 with open(config_file, "r") as f:
33 if re.match('^\s*$', config_line):
35 if re.match('^\s*#', config_line):
37 var, val = config_line.rstrip().split('=', 2)
41 def flag_is_true(key):
42 return get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes'])
44 def get(key, default_val=None):
45 return settings().get(key, default_val)