implement 'config.accumulate()' (#994)

This commit is contained in:
Mike Fährmann
2020-09-14 21:13:08 +02:00
parent 3afd362e2e
commit 392d022b04
2 changed files with 41 additions and 0 deletions

View File

@@ -140,6 +140,25 @@ def interpolate_common(common, paths, key, default=None, *, conf=_config):
return default
def accumulate(path, key, *, conf=_config):
"""Accumulate the values of 'key' along 'path'"""
result = []
try:
if key in conf:
value = conf[key]
if value:
result.extend(value)
for p in path:
conf = conf[p]
if key in conf:
value = conf[key]
if value:
result[:0] = value
except Exception:
pass
return result
def set(path, key, value, *, conf=_config):
"""Set the value of property 'key' for this session"""
for p in path: