Match all files but validate extensions

This commit is contained in:
Jeremy Stretch 2019-12-26 15:36:28 -05:00
parent 657826d2e9
commit 912b0187d7

View File

@ -10,7 +10,7 @@ def _get_definition_files():
"""
Return a list of all definition files.
"""
return [f for f in glob.glob("device-types/**/*.yaml", recursive=True)]
return [f for f in glob.glob("device-types/*/*", recursive=True)]
# Initialize schema
@ -34,6 +34,9 @@ def test_definition(file_path):
"""
Validate DeviceType definitions using the provided JSON schema.
"""
# Check file extension
assert file_path.split('.')[-1] in ('yaml', 'yml'), f"Invalid file extension: {file_path}"
# Read file
with open(file_path) as definition_file:
definition = yaml.load(definition_file.read(), Loader=yaml.SafeLoader)