21223: Add a few more --file-cache RLIMIT_NOFILE tests
[arvados.git] / sdk / python / arvados / config.py
index d293a31b8abf13c061010c4b026112e6a12b4bf1..6f3bd027901181a5e68e79218d383dec4d13c32a 100644 (file)
@@ -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)