X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f56d3a6876f246f78d5bc231a0ac5b6e4c6bdb9c..94c05a1d46dfda5766c3a3a6a220e3471fd4b5ec:/sdk/python/arvados/config.py diff --git a/sdk/python/arvados/config.py b/sdk/python/arvados/config.py index d293a31b8a..6f3bd02790 100644 --- a/sdk/python/arvados/config.py +++ b/sdk/python/arvados/config.py @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + # config.py - configuration settings and global variables for Arvados clients # # Arvados configuration settings are taken from $HOME/.config/arvados. @@ -34,16 +38,16 @@ def load(config_file): cfg = {} with open(config_file, "r") as f: for config_line in f: - if re.match('^\s*$', config_line): - continue - if re.match('^\s*#', config_line): + if re.match(r'^\s*(?:#|$)', config_line): continue var, val = config_line.rstrip().split('=', 2) cfg[var] = val return cfg -def flag_is_true(key): - return get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes']) +def flag_is_true(key, d=None): + if d is None: + d = settings() + return d.get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes']) def get(key, default_val=None): return settings().get(key, default_val)