Skip to content

Commit 23ea39b

Browse files
cmickeybprakashngit
authored andcommitted
Improve merging of config files
When loading toml config files, new files would completely overwrite the values associated with root keys in the old files. This change allows for a cleaner merge when some values overwrite and some just extend. Include new python module mergedeep (MIT license) Signed-off-by: Mic Bowman <[email protected]>
1 parent d225dfc commit 23ea39b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

build/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ $(PYTHON_DIR) :
100100
. $(abspath $(DSTDIR)/bin/activate) && pip install --upgrade websocket-client
101101
. $(abspath $(DSTDIR)/bin/activate) && pip install --upgrade msgpack
102102
. $(abspath $(DSTDIR)/bin/activate) && pip install --upgrade ccf==1.0.19
103+
. $(abspath $(DSTDIR)/bin/activate) && pip install --upgrade mergedeep
103104

104105
$(DSTDIR) :
105106
@echo CREATE INSTALLATION DIRECTORY $(DSTDIR)

python/pdo/common/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
before logging is enabled.
2121
"""
2222

23+
import mergedeep
2324
import os
2425
import sys
2526
import warnings
@@ -89,7 +90,7 @@ def parse_configuration_files(cfiles, search_path, variable_map = None) :
8990

9091
for filename in files_found :
9192
try :
92-
config.update(parse_configuration_file(filename, variable_map))
93+
mergedeep.merge(config, parse_configuration_file(filename, variable_map))
9394
except IOError as detail :
9495
raise ConfigurationException(filename, "IO error; {0}".format(str(detail)))
9596
except ValueError as detail :

0 commit comments

Comments
 (0)