Skip to content

Commit

Permalink
Merge pull request #23 from matthewrmshin/bugfix/include-merge-proces…
Browse files Browse the repository at this point in the history
…s-substitution

Fix include merge variable substitution
  • Loading branch information
matthewrmshin authored Jul 17, 2024
2 parents c2962fd + 0b724f2 commit d6ed899
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/yamlprocessor/dataprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ def process_data(self, in_filename: str, out_filename: str) -> None:
del data[key]
item = None
for include_key, include_item in include_data.items():
data[include_key] = include_item
data[include_key] = self.process_variable(
include_item, variable_map)
skip_keys.add(include_key)
if (
isinstance(include_item, dict)
Expand Down
8 changes: 7 additions & 1 deletion src/yamlprocessor/tests/test_dataprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ def test_main_13(tmp_path, yaml):
cat_data = {
'chase': ['rodents', 'birds'],
'like': ['food', 'play', 'sleep'],
'think': '$CAT_THINK',
}
infilename = tmp_path / 'root.yaml'
with infilename.open('w') as infile:
Expand All @@ -467,13 +468,18 @@ def test_main_13(tmp_path, yaml):
with include_infilename.open('w') as infile:
yaml.dump(cat_data, infile)
outfilename = tmp_path / 'b.yaml'
main([str(infilename), str(outfilename)])
main([
str(infilename),
str(outfilename),
'-D', 'CAT_THINK=humans are cats',
])
assert yaml.load(outfilename.open()) == {
'cat': {
'speak': ['meow', 'miaow'],
'young': 'kitten',
'chase': ['rodents', 'birds'],
'like': ['food', 'play', 'sleep'],
'think': 'humans are cats',
},
}

Expand Down

0 comments on commit d6ed899

Please sign in to comment.