config: allow env.yaml to contain configuration in a single file

- add `SingleFileScope` to configuration, which allows us to pull config
  sections from a single file.

- update `env.yaml` and tests to ensure that the env.yaml schema works
  when pulling configurtion from the env file.
This commit is contained in:
Todd Gamblin
2018-09-03 23:46:25 -07:00
parent 9ee2623486
commit 6af5dfbbc2
8 changed files with 271 additions and 81 deletions

View File

@@ -146,6 +146,26 @@ def has_method(cls, name):
return False
def union_dicts(*dicts):
"""Use update() to combine all dicts into one.
This builds a new dictionary, into which we ``update()`` each element
of ``dicts`` in order. Items from later dictionaries will override
items from earlier dictionaries.
Args:
dicts (list): list of dictionaries
Return: (dict): a merged dictionary containing combined keys and
values from ``dicts``.
"""
result = {}
for d in dicts:
result.update(d)
return result
class memoized(object):
"""Decorator that caches the results of a function, storing them
in an attribute of that function."""

View File

@@ -10,7 +10,7 @@
import os
import sys
from six import StringIO
from six import StringIO, text_type
from llnl.util.tty import terminal_size
from llnl.util.tty.color import clen, cextra
@@ -137,7 +137,7 @@ def colify(elts, **options):
% next(options.iterkeys()))
# elts needs to be an array of strings so we can count the elements
elts = [str(elt) for elt in elts]
elts = [text_type(elt) for elt in elts]
if not elts:
return (0, ())