diff options
Diffstat (limited to 'lib/python/qmk')
| -rw-r--r-- | lib/python/qmk/cli/find.py | 2 | ||||
| -rwxr-xr-x | lib/python/qmk/cli/mass_compile.py | 2 | ||||
| -rw-r--r-- | lib/python/qmk/info.py | 22 | ||||
| -rw-r--r-- | lib/python/qmk/util.py | 21 |
4 files changed, 38 insertions, 9 deletions
diff --git a/lib/python/qmk/cli/find.py b/lib/python/qmk/cli/find.py index bfed91e22c..7d8b1b066c 100644 --- a/lib/python/qmk/cli/find.py +++ b/lib/python/qmk/cli/find.py | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | """Command to search through all keyboards and keymaps for a given search criteria. | 1 | """Command to search through all keyboards and keymaps for a given search criteria. |
| 2 | """ | 2 | """ |
| 3 | import os | ||
| 3 | from milc import cli | 4 | from milc import cli |
| 4 | from qmk.search import filter_help, search_keymap_targets | 5 | from qmk.search import filter_help, search_keymap_targets |
| 5 | from qmk.util import maybe_exit_config | 6 | from qmk.util import maybe_exit_config |
| @@ -20,6 +21,7 @@ from qmk.util import maybe_exit_config | |||
| 20 | def find(cli): | 21 | def find(cli): |
| 21 | """Search through all keyboards and keymaps for a given search criteria. | 22 | """Search through all keyboards and keymaps for a given search criteria. |
| 22 | """ | 23 | """ |
| 24 | os.environ.setdefault('SKIP_SCHEMA_VALIDATION', '1') | ||
| 23 | maybe_exit_config(should_exit=False, should_reraise=True) | 25 | maybe_exit_config(should_exit=False, should_reraise=True) |
| 24 | 26 | ||
| 25 | targets = search_keymap_targets([('all', cli.config.find.keymap)], cli.args.filter) | 27 | targets = search_keymap_targets([('all', cli.config.find.keymap)], cli.args.filter) |
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py index cf9be0fd1e..4c4669d451 100755 --- a/lib/python/qmk/cli/mass_compile.py +++ b/lib/python/qmk/cli/mass_compile.py | |||
| @@ -20,6 +20,8 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool, | |||
| 20 | if len(targets) == 0: | 20 | if len(targets) == 0: |
| 21 | return | 21 | return |
| 22 | 22 | ||
| 23 | os.environ.setdefault('SKIP_SCHEMA_VALIDATION', '1') | ||
| 24 | |||
| 23 | make_cmd = find_make() | 25 | make_cmd = find_make() |
| 24 | builddir = Path(QMK_FIRMWARE) / '.build' | 26 | builddir = Path(QMK_FIRMWARE) / '.build' |
| 25 | makefile = builddir / 'parallel_kb_builds.mk' | 27 | makefile = builddir / 'parallel_kb_builds.mk' |
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 72b19a9fec..82082f5cf0 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | """Functions that help us generate and use info.json files. | 1 | """Functions that help us generate and use info.json files. |
| 2 | """ | 2 | """ |
| 3 | import re | 3 | import re |
| 4 | import os | ||
| 4 | from pathlib import Path | 5 | from pathlib import Path |
| 5 | import jsonschema | 6 | import jsonschema |
| 6 | from dotty_dict import dotty | 7 | from dotty_dict import dotty |
| @@ -14,7 +15,7 @@ from qmk.keyboard import config_h, rules_mk | |||
| 14 | from qmk.commands import parse_configurator_json | 15 | from qmk.commands import parse_configurator_json |
| 15 | from qmk.makefile import parse_rules_mk_file | 16 | from qmk.makefile import parse_rules_mk_file |
| 16 | from qmk.math import compute | 17 | from qmk.math import compute |
| 17 | from qmk.util import maybe_exit | 18 | from qmk.util import maybe_exit, truthy |
| 18 | 19 | ||
| 19 | true_values = ['1', 'on', 'yes'] | 20 | true_values = ['1', 'on', 'yes'] |
| 20 | false_values = ['0', 'off', 'no'] | 21 | false_values = ['0', 'off', 'no'] |
| @@ -262,7 +263,9 @@ def info_json(keyboard, force_layout=None): | |||
| 262 | info_data["community_layouts"] = [force_layout] | 263 | info_data["community_layouts"] = [force_layout] |
| 263 | 264 | ||
| 264 | # Validate | 265 | # Validate |
| 265 | _validate(keyboard, info_data) | 266 | # Skip processing if necessary |
| 267 | if not truthy(os.environ.get('SKIP_SCHEMA_VALIDATION'), False): | ||
| 268 | _validate(keyboard, info_data) | ||
| 266 | 269 | ||
| 267 | # Check that the reported matrix size is consistent with the actual matrix size | 270 | # Check that the reported matrix size is consistent with the actual matrix size |
| 268 | _check_matrix(info_data) | 271 | _check_matrix(info_data) |
| @@ -944,13 +947,14 @@ def merge_info_jsons(keyboard, info_data): | |||
| 944 | _log_error(info_data, "Invalid file %s, root object should be a dictionary." % (str(info_file),)) | 947 | _log_error(info_data, "Invalid file %s, root object should be a dictionary." % (str(info_file),)) |
| 945 | continue | 948 | continue |
| 946 | 949 | ||
| 947 | try: | 950 | if not truthy(os.environ.get('SKIP_SCHEMA_VALIDATION'), False): |
| 948 | validate(new_info_data, 'qmk.keyboard.v1') | 951 | try: |
| 949 | except jsonschema.ValidationError as e: | 952 | validate(new_info_data, 'qmk.keyboard.v1') |
| 950 | json_path = '.'.join([str(p) for p in e.absolute_path]) | 953 | except jsonschema.ValidationError as e: |
| 951 | cli.log.error('Not including data from file: %s', info_file) | 954 | json_path = '.'.join([str(p) for p in e.absolute_path]) |
| 952 | cli.log.error('\t%s: %s', json_path, e.message) | 955 | cli.log.error('Not including data from file: %s', info_file) |
| 953 | continue | 956 | cli.log.error('\t%s: %s', json_path, e.message) |
| 957 | continue | ||
| 954 | 958 | ||
| 955 | # Merge layout data in | 959 | # Merge layout data in |
| 956 | if 'layout_aliases' in new_info_data: | 960 | if 'layout_aliases' in new_info_data: |
diff --git a/lib/python/qmk/util.py b/lib/python/qmk/util.py index b73fab89d1..8f99410e1d 100644 --- a/lib/python/qmk/util.py +++ b/lib/python/qmk/util.py | |||
| @@ -27,6 +27,27 @@ def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False): | |||
| 27 | maybe_exit_reraise = should_reraise | 27 | maybe_exit_reraise = should_reraise |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | def truthy(value, value_if_unknown=False): | ||
| 31 | """Returns True if the value is truthy, False otherwise. | ||
| 32 | |||
| 33 | Deals with: | ||
| 34 | True: 1, true, t, yes, y, on | ||
| 35 | False: 0, false, f, no, n, off | ||
| 36 | """ | ||
| 37 | if value in {False, True}: | ||
| 38 | return bool(value) | ||
| 39 | |||
| 40 | test_value = str(value).strip().lower() | ||
| 41 | |||
| 42 | if test_value in {"1", "true", "t", "yes", "y", "on"}: | ||
| 43 | return True | ||
| 44 | |||
| 45 | if test_value in {"0", "false", "f", "no", "n", "off"}: | ||
| 46 | return False | ||
| 47 | |||
| 48 | return value_if_unknown | ||
| 49 | |||
| 50 | |||
| 30 | @contextlib.contextmanager | 51 | @contextlib.contextmanager |
| 31 | def parallelize(): | 52 | def parallelize(): |
| 32 | """Returns a function that can be used in place of a map() call. | 53 | """Returns a function that can be used in place of a map() call. |
