Skip to content

Commit

Permalink
Fix for round_trip_load() YAML error, refs #2219
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Dec 19, 2023
1 parent 067cc75 commit 89c8ca0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/metadata_doc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import textwrap
from yaml import safe_dump
from ruamel.yaml import round_trip_load
from ruamel.yaml import YAML


def metadata_example(cog, data=None, yaml=None):
Expand All @@ -11,8 +11,7 @@ def metadata_example(cog, data=None, yaml=None):
if yaml:
# dedent it first
yaml = textwrap.dedent(yaml).strip()
# round_trip_load to preserve key order:
data = round_trip_load(yaml)
data = YAML().load(yaml)
output_yaml = yaml
else:
output_yaml = safe_dump(data, sort_keys=False)
Expand All @@ -27,8 +26,7 @@ def metadata_example(cog, data=None, yaml=None):

def config_example(cog, input):
if type(input) is str:
# round_trip_load to preserve key order:
data = round_trip_load(input)
data = YAML().load(input)
output_yaml = input
else:
data = input
Expand Down

0 comments on commit 89c8ca0

Please sign in to comment.