Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
commit
f872fbea7e
4 changed files with 26 additions and 26 deletions
|
@ -5,10 +5,9 @@ from pathlib import Path
|
||||||
from dotty_dict import dotty
|
from dotty_dict import dotty
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
from qmk.info import info_json
|
from qmk.info import info_json, keymap_json_config
|
||||||
from qmk.json_schema import json_load, validate
|
from qmk.json_schema import json_load
|
||||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||||
from qmk.keymap import locate_keymap
|
|
||||||
from qmk.commands import dump_lines
|
from qmk.commands import dump_lines
|
||||||
from qmk.path import normpath
|
from qmk.path import normpath
|
||||||
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
||||||
|
@ -180,10 +179,7 @@ def generate_config_h(cli):
|
||||||
"""
|
"""
|
||||||
# Determine our keyboard/keymap
|
# Determine our keyboard/keymap
|
||||||
if cli.args.keymap:
|
if cli.args.keymap:
|
||||||
km = locate_keymap(cli.args.keyboard, cli.args.keymap)
|
kb_info_json = dotty(keymap_json_config(cli.args.keyboard, cli.args.keymap))
|
||||||
km_json = json_load(km)
|
|
||||||
validate(km_json, 'qmk.keymap.v1')
|
|
||||||
kb_info_json = dotty(km_json.get('config', {}))
|
|
||||||
else:
|
else:
|
||||||
kb_info_json = dotty(info_json(cli.args.keyboard))
|
kb_info_json = dotty(info_json(cli.args.keyboard))
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ from pathlib import Path
|
||||||
from dotty_dict import dotty
|
from dotty_dict import dotty
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
from qmk.info import info_json
|
from qmk.info import info_json, keymap_json_config
|
||||||
from qmk.json_schema import json_load, validate
|
from qmk.json_schema import json_load
|
||||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||||
from qmk.keymap import locate_keymap
|
|
||||||
from qmk.commands import dump_lines
|
from qmk.commands import dump_lines
|
||||||
from qmk.path import normpath
|
from qmk.path import normpath
|
||||||
from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
|
from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
|
||||||
|
@ -51,10 +50,7 @@ def generate_rules_mk(cli):
|
||||||
"""
|
"""
|
||||||
# Determine our keyboard/keymap
|
# Determine our keyboard/keymap
|
||||||
if cli.args.keymap:
|
if cli.args.keymap:
|
||||||
km = locate_keymap(cli.args.keyboard, cli.args.keymap)
|
kb_info_json = dotty(keymap_json_config(cli.args.keyboard, cli.args.keymap))
|
||||||
km_json = json_load(km)
|
|
||||||
validate(km_json, 'qmk.keymap.v1')
|
|
||||||
kb_info_json = dotty(km_json.get('config', {}))
|
|
||||||
else:
|
else:
|
||||||
kb_info_json = dotty(info_json(cli.args.keyboard))
|
kb_info_json = dotty(info_json(cli.args.keyboard))
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ from qmk.json_encoders import InfoJSONEncoder
|
||||||
from qmk.constants import COL_LETTERS, ROW_LETTERS
|
from qmk.constants import COL_LETTERS, ROW_LETTERS
|
||||||
from qmk.decorators import automagic_keyboard, automagic_keymap
|
from qmk.decorators import automagic_keyboard, automagic_keymap
|
||||||
from qmk.keyboard import keyboard_completer, keyboard_folder, render_layouts, render_layout, rules_mk
|
from qmk.keyboard import keyboard_completer, keyboard_folder, render_layouts, render_layout, rules_mk
|
||||||
|
from qmk.info import info_json, keymap_json
|
||||||
from qmk.keymap import locate_keymap
|
from qmk.keymap import locate_keymap
|
||||||
from qmk.info import info_json
|
|
||||||
from qmk.path import is_keyboard
|
from qmk.path import is_keyboard
|
||||||
|
|
||||||
UNICODE_SUPPORT = sys.stdout.encoding.lower().startswith('utf')
|
UNICODE_SUPPORT = sys.stdout.encoding.lower().startswith('utf')
|
||||||
|
@ -135,7 +135,7 @@ def print_parsed_rules_mk(keyboard_name):
|
||||||
|
|
||||||
|
|
||||||
@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.')
|
@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Keyboard to show info for.')
|
||||||
@cli.argument('-km', '--keymap', help='Show the layers for a JSON keymap too.')
|
@cli.argument('-km', '--keymap', help='Keymap to show info for (Optional).')
|
||||||
@cli.argument('-l', '--layouts', action='store_true', help='Render the layouts.')
|
@cli.argument('-l', '--layouts', action='store_true', help='Render the layouts.')
|
||||||
@cli.argument('-m', '--matrix', action='store_true', help='Render the layouts with matrix information.')
|
@cli.argument('-m', '--matrix', action='store_true', help='Render the layouts with matrix information.')
|
||||||
@cli.argument('-f', '--format', default='friendly', arg_only=True, help='Format to display the data in (friendly, text, json) (Default: friendly).')
|
@cli.argument('-f', '--format', default='friendly', arg_only=True, help='Format to display the data in (friendly, text, json) (Default: friendly).')
|
||||||
|
@ -161,8 +161,15 @@ def info(cli):
|
||||||
print_parsed_rules_mk(cli.config.info.keyboard)
|
print_parsed_rules_mk(cli.config.info.keyboard)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# default keymap stored in config file should be ignored
|
||||||
|
if cli.config_source.info.keymap == 'config_file':
|
||||||
|
cli.config_source.info.keymap = None
|
||||||
|
|
||||||
# Build the info.json file
|
# Build the info.json file
|
||||||
kb_info_json = info_json(cli.config.info.keyboard)
|
if cli.config.info.keymap:
|
||||||
|
kb_info_json = keymap_json(cli.config.info.keyboard, cli.config.info.keymap)
|
||||||
|
else:
|
||||||
|
kb_info_json = info_json(cli.config.info.keyboard)
|
||||||
|
|
||||||
# Output in the requested format
|
# Output in the requested format
|
||||||
if cli.args.format == 'json':
|
if cli.args.format == 'json':
|
||||||
|
@ -178,11 +185,12 @@ def info(cli):
|
||||||
cli.log.error('Unknown format: %s', cli.args.format)
|
cli.log.error('Unknown format: %s', cli.args.format)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Output requested extras
|
||||||
if cli.config.info.layouts:
|
if cli.config.info.layouts:
|
||||||
show_layouts(kb_info_json, title_caps)
|
show_layouts(kb_info_json, title_caps)
|
||||||
|
|
||||||
if cli.config.info.matrix:
|
if cli.config.info.matrix:
|
||||||
show_matrix(kb_info_json, title_caps)
|
show_matrix(kb_info_json, title_caps)
|
||||||
|
|
||||||
if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file':
|
if cli.config.info.keymap:
|
||||||
show_keymap(kb_info_json, title_caps)
|
show_keymap(kb_info_json, title_caps)
|
||||||
|
|
|
@ -12,6 +12,7 @@ from qmk.c_parse import find_layouts, parse_config_h_file
|
||||||
from qmk.json_schema import deep_update, json_load, validate
|
from qmk.json_schema import deep_update, json_load, validate
|
||||||
from qmk.keyboard import config_h, rules_mk
|
from qmk.keyboard import config_h, rules_mk
|
||||||
from qmk.keymap import list_keymaps, locate_keymap
|
from qmk.keymap import list_keymaps, locate_keymap
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -769,14 +770,13 @@ def find_info_json(keyboard):
|
||||||
return [info_json for info_json in info_jsons if info_json.exists()]
|
return [info_json for info_json in info_jsons if info_json.exists()]
|
||||||
|
|
||||||
|
|
||||||
def parse_keymap_json_file(file):
|
def keymap_json_config(keyboard, keymap):
|
||||||
"""load a valid keymap.json
|
"""Extract keymap level config
|
||||||
"""
|
"""
|
||||||
if not file.exists():
|
keymap_folder = locate_keymap(keyboard, keymap).parent
|
||||||
return {}
|
|
||||||
km_info_json = json_load(file)
|
km_info_json = parse_configurator_json(keymap_folder / 'keymap.json')
|
||||||
validate(km_info_json, 'qmk.keymap.v1')
|
return km_info_json.get('config', {})
|
||||||
return km_info_json
|
|
||||||
|
|
||||||
|
|
||||||
def keymap_json(keyboard, keymap):
|
def keymap_json(keyboard, keymap):
|
||||||
|
@ -793,7 +793,7 @@ def keymap_json(keyboard, keymap):
|
||||||
kb_info_json = info_json(keyboard)
|
kb_info_json = info_json(keyboard)
|
||||||
|
|
||||||
# Merge in the data from keymap.json
|
# Merge in the data from keymap.json
|
||||||
km_info_json = parse_keymap_json_file(keymap_file).get('config', {})
|
km_info_json = keymap_json_config(keyboard, keymap) if keymap_file.exists() else {}
|
||||||
deep_update(kb_info_json, km_info_json)
|
deep_update(kb_info_json, km_info_json)
|
||||||
|
|
||||||
# Merge in the data from config.h, and rules.mk
|
# Merge in the data from config.h, and rules.mk
|
||||||
|
|
Loading…
Reference in a new issue