mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-24 01:17:07 +06:00
Speed improvements to qmk find
. (#24385)
This commit is contained in:
parent
4f9ef90754
commit
580d18d2e9
|
@ -1,5 +1,6 @@
|
||||||
"""Command to search through all keyboards and keymaps for a given search criteria.
|
"""Command to search through all keyboards and keymaps for a given search criteria.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
from milc import cli
|
from milc import cli
|
||||||
from qmk.search import filter_help, search_keymap_targets
|
from qmk.search import filter_help, search_keymap_targets
|
||||||
from qmk.util import maybe_exit_config
|
from qmk.util import maybe_exit_config
|
||||||
|
@ -20,6 +21,7 @@ from qmk.util import maybe_exit_config
|
||||||
def find(cli):
|
def find(cli):
|
||||||
"""Search through all keyboards and keymaps for a given search criteria.
|
"""Search through all keyboards and keymaps for a given search criteria.
|
||||||
"""
|
"""
|
||||||
|
os.environ.setdefault('SKIP_SCHEMA_VALIDATION', '1')
|
||||||
maybe_exit_config(should_exit=False, should_reraise=True)
|
maybe_exit_config(should_exit=False, should_reraise=True)
|
||||||
|
|
||||||
targets = search_keymap_targets([('all', cli.config.find.keymap)], cli.args.filter)
|
targets = search_keymap_targets([('all', cli.config.find.keymap)], cli.args.filter)
|
||||||
|
|
|
@ -20,6 +20,8 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
|
||||||
if len(targets) == 0:
|
if len(targets) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
os.environ.setdefault('SKIP_SCHEMA_VALIDATION', '1')
|
||||||
|
|
||||||
make_cmd = find_make()
|
make_cmd = find_make()
|
||||||
builddir = Path(QMK_FIRMWARE) / '.build'
|
builddir = Path(QMK_FIRMWARE) / '.build'
|
||||||
makefile = builddir / 'parallel_kb_builds.mk'
|
makefile = builddir / 'parallel_kb_builds.mk'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Functions that help us generate and use info.json files.
|
"""Functions that help us generate and use info.json files.
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import jsonschema
|
import jsonschema
|
||||||
from dotty_dict import dotty
|
from dotty_dict import dotty
|
||||||
|
@ -14,7 +15,7 @@ from qmk.keyboard import config_h, rules_mk
|
||||||
from qmk.commands import parse_configurator_json
|
from qmk.commands import parse_configurator_json
|
||||||
from qmk.makefile import parse_rules_mk_file
|
from qmk.makefile import parse_rules_mk_file
|
||||||
from qmk.math import compute
|
from qmk.math import compute
|
||||||
from qmk.util import maybe_exit
|
from qmk.util import maybe_exit, truthy
|
||||||
|
|
||||||
true_values = ['1', 'on', 'yes']
|
true_values = ['1', 'on', 'yes']
|
||||||
false_values = ['0', 'off', 'no']
|
false_values = ['0', 'off', 'no']
|
||||||
|
@ -262,7 +263,9 @@ def info_json(keyboard, force_layout=None):
|
||||||
info_data["community_layouts"] = [force_layout]
|
info_data["community_layouts"] = [force_layout]
|
||||||
|
|
||||||
# Validate
|
# Validate
|
||||||
_validate(keyboard, info_data)
|
# Skip processing if necessary
|
||||||
|
if not truthy(os.environ.get('SKIP_SCHEMA_VALIDATION'), False):
|
||||||
|
_validate(keyboard, info_data)
|
||||||
|
|
||||||
# Check that the reported matrix size is consistent with the actual matrix size
|
# Check that the reported matrix size is consistent with the actual matrix size
|
||||||
_check_matrix(info_data)
|
_check_matrix(info_data)
|
||||||
|
@ -944,13 +947,14 @@ def merge_info_jsons(keyboard, info_data):
|
||||||
_log_error(info_data, "Invalid file %s, root object should be a dictionary." % (str(info_file),))
|
_log_error(info_data, "Invalid file %s, root object should be a dictionary." % (str(info_file),))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
if not truthy(os.environ.get('SKIP_SCHEMA_VALIDATION'), False):
|
||||||
validate(new_info_data, 'qmk.keyboard.v1')
|
try:
|
||||||
except jsonschema.ValidationError as e:
|
validate(new_info_data, 'qmk.keyboard.v1')
|
||||||
json_path = '.'.join([str(p) for p in e.absolute_path])
|
except jsonschema.ValidationError as e:
|
||||||
cli.log.error('Not including data from file: %s', info_file)
|
json_path = '.'.join([str(p) for p in e.absolute_path])
|
||||||
cli.log.error('\t%s: %s', json_path, e.message)
|
cli.log.error('Not including data from file: %s', info_file)
|
||||||
continue
|
cli.log.error('\t%s: %s', json_path, e.message)
|
||||||
|
continue
|
||||||
|
|
||||||
# Merge layout data in
|
# Merge layout data in
|
||||||
if 'layout_aliases' in new_info_data:
|
if 'layout_aliases' in new_info_data:
|
||||||
|
|
|
@ -27,6 +27,27 @@ def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False):
|
||||||
maybe_exit_reraise = should_reraise
|
maybe_exit_reraise = should_reraise
|
||||||
|
|
||||||
|
|
||||||
|
def truthy(value, value_if_unknown=False):
|
||||||
|
"""Returns True if the value is truthy, False otherwise.
|
||||||
|
|
||||||
|
Deals with:
|
||||||
|
True: 1, true, t, yes, y, on
|
||||||
|
False: 0, false, f, no, n, off
|
||||||
|
"""
|
||||||
|
if value in {False, True}:
|
||||||
|
return bool(value)
|
||||||
|
|
||||||
|
test_value = str(value).strip().lower()
|
||||||
|
|
||||||
|
if test_value in {"1", "true", "t", "yes", "y", "on"}:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if test_value in {"0", "false", "f", "no", "n", "off"}:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return value_if_unknown
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def parallelize():
|
def parallelize():
|
||||||
"""Returns a function that can be used in place of a map() call.
|
"""Returns a function that can be used in place of a map() call.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user