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

Enhance Readability of YAML File Output for Improved Maintenance #534

Closed
SeverusYixin opened this issue Nov 28, 2024 · 2 comments · Fixed by #545
Closed

Enhance Readability of YAML File Output for Improved Maintenance #534

SeverusYixin opened this issue Nov 28, 2024 · 2 comments · Fixed by #545
Assignees

Comments

@SeverusYixin
Copy link
Collaborator

SeverusYixin commented Nov 28, 2024

As the content in the YAML file continues to grow, improving its readability would significantly benefit maintenance efforts. Currently, the script's output is functional and displays correctly on the website, but the format in the YAML file after be normalized should make it easier to read and manage.

Proposal:
Modify the script's output to improve the formatting and readability of the generated YAML file.

  1. Ensure that the YAML file remains clear and maintainable as the data grows.
  2. Keep the output consistent with the standards for better collaboration and future updates.

This issue related to #533 (comment)

@SeverusYixin SeverusYixin self-assigned this Nov 28, 2024
@haesleinhuepf
Copy link
Member

Let me just add some substance to this issue: I presume this script: scripts/data_normalizer.py makes umlauts less readable when modifying our yml file. For example it turns Maximilian Müller into Maximilian M\xFCller.

git-bob think about how this could be resolved.

Copy link
Contributor

This message was generated by git-bob (version: 0.14.0, model: github_models:gpt-4o, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To improve the readability of the YAML file and address the issue with umlauts being converted to escape sequences, you can modify the write_data_to_file function to specify an encoding option that handles Unicode characters appropriately. Here's a proposed change:

def write_data_to_file(data, file_path):
    """
    Writes data to a YAML file with improved readability for Unicode characters.

    Parameters
    ----------
    data : dict
        The data to be written.
    file_path : str
        The path to the YAML file.
    """
    os.makedirs(os.path.dirname(file_path), exist_ok=True)
    with open(file_path, 'w', encoding='utf-8') as file:
        yaml.dump(data, file, sort_keys=False, allow_unicode=True)

This modification uses allow_unicode=True in the yaml.dump method, which preserves Unicode characters like ü in their readable form instead of converting them into escape sequences. This should enhance the readability and maintainability of the YAML file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants