Skip to content

Commit

Permalink
updated recursive function within ordereddict
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirAE committed Feb 28, 2024
1 parent 173909a commit c7c1208
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/uwtools/config/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ def represent_ordereddict(dumper: yaml.Dumper, data: OrderedDict) -> yaml.nodes.
:param data: The ordereddict to serialize.
"""
# Convert the Ordered Dict to a dictionary
for key, value in data.items():
if isinstance(value, OrderedDict):
data[key] = dict(value)
def from_od(d: Union[OrderedDict, Dict]) -> dict:
return {key: from_od(val) if isinstance(val, dict) else val for key, val in d.items()}

# Represent the dictionary as a YAML mapping
return dumper.represent_mapping("tag:yaml.org,2002:map", data)
return dumper.represent_mapping("tag:yaml.org,2002:map", from_od(data))


class TaggedString:
Expand Down

0 comments on commit c7c1208

Please sign in to comment.