diff options
author | Joel Challis <git@zvecr.com> | 2023-03-28 02:53:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 02:53:28 +0100 |
commit | f186abdf29874bef9e577006c7689d09b6ea16fb (patch) | |
tree | 0bffa02bc212ba304d3edf2636342339965dac08 /lib | |
parent | c485d1cf2652bfb47afbb68f128a64f1bc518aa3 (diff) |
Reduce _validate complexity (#20274)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/info.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index f4dcc507ef..924d31ac81 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -50,18 +50,9 @@ def _valid_community_layout(layout): return (Path('layouts/default') / layout).exists() -def _validate(keyboard, info_data): - """Perform various validation on the provided info.json data +def _additional_validation(keyboard, info_data): + """Non schema checks """ - # First validate against the jsonschema - try: - validate(info_data, 'qmk.api.keyboard.v1') - - except jsonschema.ValidationError as e: - json_path = '.'.join([str(p) for p in e.absolute_path]) - cli.log.error('Invalid API data: %s: %s: %s', keyboard, json_path, e.message) - exit(1) - layouts = info_data.get('layouts', {}) layout_aliases = info_data.get('layout_aliases', {}) community_layouts = info_data.get('community_layouts', []) @@ -110,6 +101,21 @@ def _validate(keyboard, info_data): _log_error(info_data, f'Keycode {decl["key"]} has no short form alias') +def _validate(keyboard, info_data): + """Perform various validation on the provided info.json data + """ + # First validate against the jsonschema + try: + validate(info_data, 'qmk.api.keyboard.v1') + + _additional_validation(keyboard, info_data) + + except jsonschema.ValidationError as e: + json_path = '.'.join([str(p) for p in e.absolute_path]) + cli.log.error('Invalid API data: %s: %s: %s', keyboard, json_path, e.message) + exit(1) + + def info_json(keyboard): """Generate the info.json data for a specific keyboard. """ |