diff options
author | Magnus Ahltorp <map@kth.se> | 2017-06-30 10:48:21 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-07-06 17:48:30 +0200 |
commit | 4e44c1e8a4ea6ec4c5eeb2a1a05d93e076c7fd50 (patch) | |
tree | d4a6945f3399324e4db99673449c425ebd9e3c78 /tools/readconfig.py | |
parent | bb71cbabaac8baf18f7a685339f0e2670b019d91 (diff) |
Replace 'localnodes' config with 'nodename'
Also some cleanup
Diffstat (limited to 'tools/readconfig.py')
-rw-r--r-- | tools/readconfig.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/readconfig.py b/tools/readconfig.py index 69531ca..028e319 100644 --- a/tools/readconfig.py +++ b/tools/readconfig.py @@ -5,16 +5,19 @@ import yaml import base64 import sys +def render_path(path): + if path: + return "'" + ", ".join(path) + "'" + else: + return "the top level" + class ErrorHandlingDict(dict): def __init__(self, filename, path): self._filename = filename self._path = path dict.__init__({}) def __missing__(self, key): - if self._path: - path = ", ".join(self._path) - else: - path = "the top level" + path = render_path(self._path) print >>sys.stderr, "error: could not find configuration key '%s' at %s in %s" % (key, path, self._filename) sys.exit(1) @@ -52,8 +55,9 @@ def verify_and_read_config(filename, publickey_base64): signature = open(filename + ".sig").read() verify_config(rawconfig, signature, publickey_base64, filename) - - return errorhandlify(yaml.load(io.BytesIO(rawconfig), yaml.SafeLoader), filename) + config = yaml.load(io.BytesIO(rawconfig), yaml.SafeLoader) + return errorhandlify(config, filename) def read_config(filename): - return errorhandlify(yaml.load(open(filename), yaml.SafeLoader), filename) + config = yaml.load(open(filename), yaml.SafeLoader) + return errorhandlify(config, filename) |