scripts: modules: Use pathlib to locate the module file
Instead of using strings, use pathlib's functionality to handle the
fact that it can have two different extensions.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py
index 4033f65..9bf14cd 100755
--- a/scripts/zephyr_module.py
+++ b/scripts/zephyr_module.py
@@ -97,6 +97,8 @@
- type: str
'''
+MODULE_YML_PATH = PurePath('zephyr/module.yml')
+
schema = yaml.safe_load(METADATA_SCHEMA)
@@ -114,11 +116,11 @@
def process_module(module):
module_path = PurePath(module)
- # The input is a module if zephyr/module.yml is a valid yaml file
+ # The input is a module if zephyr/module.{yml,yaml} is a valid yaml file
# or if both zephyr/CMakeLists.txt and zephyr/Kconfig are present.
- for module_yml in [module_path.joinpath('zephyr/module.yml'),
- module_path.joinpath('zephyr/module.yaml')]:
+ 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:
meta = yaml.safe_load(f.read())