scripts: Read yaml files using utf-8 encoding

By default Windows does not use utf-8 encoding for reading files,
set is explicitly.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-10-15 08:58:36 +02:00 committed by Carles Cufí
parent 9e8b7bd3ad
commit ca3dc019b7
5 changed files with 5 additions and 5 deletions

View File

@ -246,7 +246,7 @@ class Filters:
c = (zephyr_base / changed).resolve()
if c.is_relative_to(board.dir.resolve()):
for file in glob.glob(os.path.join(board.dir, f"{board.name}*.yaml")):
with open(file, 'r') as f:
with open(file, 'r', encoding='utf-8') as f:
b = yaml.load(f.read(), Loader=SafeLoader)
matched_boards[b['identifier']] = board

View File

@ -183,7 +183,7 @@ def find_arch2board_set_in(root, arches, board_dir):
def load_v2_boards(board_name, board_yml, systems):
boards = []
if board_yml.is_file():
with board_yml.open('r') as f:
with board_yml.open('r', encoding='utf-8') as f:
b = yaml.load(f.read(), Loader=SafeLoader)
try:

View File

@ -188,7 +188,7 @@ def find_v2_archs(args):
archs_yml = root / ARCHS_YML_PATH
if Path(archs_yml).is_file():
with Path(archs_yml).open('r') as f:
with Path(archs_yml).open('r', encoding='utf-8') as f:
archs = yaml.load(f.read(), Loader=SafeLoader)
try:

View File

@ -74,7 +74,7 @@ def board_v1_to_v2(board_root, board, new_board, group, vendor, soc, variants):
}
}
else:
with open(board_settings_file) as f:
with open(board_settings_file, encoding='utf-8') as f:
yaml = ruamel.yaml.YAML(typ='safe', pure=True)
board_settings = yaml.load(f) # pylint: disable=assignment-from-no-return

View File

@ -193,7 +193,7 @@ def process_module(module):
for module_yml in [module_path / MODULE_YML_PATH,
module_path / MODULE_YML_PATH.with_suffix('.yaml')]:
if Path(module_yml).is_file():
with Path(module_yml).open('r') as f:
with Path(module_yml).open('r', encoding='utf-8') as f:
meta = yaml.load(f.read(), Loader=SafeLoader)
try: