From 6882759044e6d48c5d01bc2e99456b51c078bf4a Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Wed, 4 Dec 2024 13:14:19 +0100 Subject: [PATCH] Enhance Readability of YAML File Output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When processing names with umlauts, such as "Maximilian Müller," the output incorrectly converts the umlaut to an escape sequence, resulting in "Maximilian M\xFCller." --- scripts/data_normalizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/data_normalizer.py b/scripts/data_normalizer.py index c2453b95..10ff658d 100644 --- a/scripts/data_normalizer.py +++ b/scripts/data_normalizer.py @@ -346,7 +346,7 @@ def read_data_from_file(file_path): def write_data_to_file(data, file_path): """ - Writes data to a YAML file. + Writes data to a YAML file with improved readability for Unicode characters. Parameters ---------- @@ -356,8 +356,8 @@ def write_data_to_file(data, file_path): The path to the YAML file. """ os.makedirs(os.path.dirname(file_path), exist_ok=True) - with open(file_path, 'w') as file: - yaml.dump(data, file, sort_keys=False) + with open(file_path, 'w', encoding='utf-8') as file: + yaml.dump(data, file, sort_keys=False, allow_unicode=True) def process_file(file_path, spdx_licenses): """