summaryrefslogtreecommitdiff
path: root/talerbank/talerconfig.py
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-04-20 00:14:09 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-04-20 00:14:09 +0200
commitbe069f1c08b66120c5ad0ef39161ac59a9c04df3 (patch)
tree7ef76daaf4194a184ce49ccf2947b766e867eb9a /talerbank/talerconfig.py
parenta3c9e11f39f8ffb1462456e65aebbf096877e410 (diff)
downloadbank-be069f1c08b66120c5ad0ef39161ac59a9c04df3.tar.gz
bank-be069f1c08b66120c5ad0ef39161ac59a9c04df3.tar.bz2
bank-be069f1c08b66120c5ad0ef39161ac59a9c04df3.zip
load config from env
Diffstat (limited to 'talerbank/talerconfig.py')
-rw-r--r--talerbank/talerconfig.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/talerbank/talerconfig.py b/talerbank/talerconfig.py
index e8dd384..74d6aff 100644
--- a/talerbank/talerconfig.py
+++ b/talerbank/talerconfig.py
@@ -1,3 +1,26 @@
+# This file is part of TALER
+# (C) 2016 INRIA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Affero General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
+#
+# @author Florian Dold
+
+"""
+Parse GNUnet-style configurations in pure Python
+"""
+
+# FIXME: make sure that autovivification of config entries
+# does not leave garbage behind (use weakrefs!)
+
import logging
import collections
import os
@@ -111,6 +134,14 @@ class TalerConfig:
return
logger.warn("no base directory found")
+ def load_env(self, dirname, *args, **kwargs):
+ """
+ Load file from environment variable TALER_CONFIG_FILE
+ or from default location if the variable is not set.
+ """
+ filename = os.environ.get("TALER_CONFIG_FILE")
+ self.load_file(filename, *args, **kwargs)
+
def load_dir(self, dirname):
try:
files = os.listdir(dirname)