Skip to content

Commit

Permalink
Merge pull request #11541 from Mab879/speedup_yaml_dumping
Browse files Browse the repository at this point in the history
Update entities/common.py to use CDumper
  • Loading branch information
jan-cerny authored Feb 5, 2024
2 parents d3ca2b8 + 507351e commit 1dfff9b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ssg/entities/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from collections import defaultdict
from copy import deepcopy

from ssg.yaml import yaml_Dumper

from ..xml import ElementTree as ET, add_xhtml_namespace
from ..yaml import DocumentationNotComplete, open_and_macro_expand
from ..shims import unicode_func
Expand Down Expand Up @@ -128,12 +130,13 @@ def derive_id_from_file_name(filename):

def dump_yaml_preferably_in_original_order(dictionary, file_object):
try:
return yaml.dump(dictionary, file_object, indent=4, sort_keys=False)
return yaml.dump(dictionary, file_object, indent=4, sort_keys=False,
Dumper=yaml_Dumper)
except TypeError as exc:
# Older versions of libyaml don't understand the sort_keys kwarg
if "sort_keys" not in str(exc):
raise exc
return yaml.dump(dictionary, file_object, indent=4)
return yaml.dump(dictionary, file_object, indent=4, Dumper=yaml_Dumper)


class XCCDFEntity(object):
Expand Down

0 comments on commit 1dfff9b

Please sign in to comment.