INNER CODE UNIT · Python

fix_yaml_file

magicsword-io/LOLRMM · bin/fix_yaml_formatting.py:111

def fix_yaml_file(file_path):
    """Fix formatting issues in a YAML file."""
    try:
        yaml = YAML()
        yaml.preserve_quotes = True
        yaml.default_flow_style = False
        yaml.indent(mapping=4, sequence=4, offset=4)
        yaml.width = 4096  # Prevent line wrapping

        # Read and parse
        with open(file_path, "r", encoding="utf-8") as f:
            data = yaml.load(f)

        # Write with ruamel.yaml
        from io import StringIO

        stream = StringIO()
        yaml.dump(data, stream)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…