Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update entities/common.py to use CDumper #11541

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice improvement. I got a speed up about 6 seconds when building RHEL 9 content.

Can you investigate if this change can be consolidated with ssg/yaml.py?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to import yaml_Dumper from ssg/yaml.py.

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
Loading