scripts/utils/board_v1_to_v2.py: couple of fixes

- the variable 'copyright' can be accessed without
   being initialized
 - the yaml package (ruamel) has been changed, the API
   yaml.safe_load() is deprecated. See error message
   with the original code below.

$ python3 ./scripts/utils/board_v1_to_v2.py -b frdm_k64f -g blob -v blob -s k6x

New board already exists, updating board with additional SoC
Moving files to the new board folder...
Creating or updating board.yaml...
Traceback (most recent call last):
File "/home/yves/sw/zephyr/zephyrproject/zephyr/./scripts/utils/board_v1_to_v2.py", line 206, in
board_v1_to_v2(
File "/home/yves/sw/zephyr/zephyrproject/zephyr/./scripts/utils/board_v1_to_v2.py", line 78, in board_v1_to_v2
board_settings = ruamel.yaml.safe_load(f) # pylint: disable=assignment-from-no-return
File "/home/yves/.local/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1105, in safe_load
error_deprecation('safe_load', 'load', arg="typ='safe', pure=True")
File "/home/yves/.local/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1039, in error_deprecation
raise AttributeError(s, name=None)
AttributeError:

"safe_load()" has been removed, use
yaml = YAML(typ='safe', pure=True)

yaml.load(...)

instead of file "/home/yves/sw/zephyr/zephyrproject/zephyr/./scripts/utils/board_v1_to_v2.py", line 78

Signed-off-by: yves <yves.vandervennet@nxp.com>
This commit is contained in:
Yves Vandervennet
2024-01-24 08:21:18 -06:00
committed by Jamie McCrae
parent 77c2c333e5
commit a5b004663b

View File

@@ -75,7 +75,8 @@ def board_v1_to_v2(board_root, board, new_board, group, vendor, soc, variants):
}
else:
with open(board_settings_file) as f:
board_settings = ruamel.yaml.safe_load(f) # pylint: disable=assignment-from-no-return
yaml = ruamel.yaml.YAML(typ='safe', pure=True)
board_settings = yaml.load(f) # pylint: disable=assignment-from-no-return
soc = {"name": soc}
if variants:
@@ -158,6 +159,7 @@ def board_v1_to_v2(board_root, board, new_board, group, vendor, soc, variants):
print(f"Creating or updating Kconfig.{new_board}...")
board_kconfig_file = new_board_path / "Kconfig.board"
copyright = None
with open(board_kconfig_file) as f:
for line in f.readlines():
if "Copyright" in line: