diff options
Diffstat (limited to 'lib/python/qmk/cli/info.py')
-rwxr-xr-x | lib/python/qmk/cli/info.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 9ab299a21e..a7ce8abf03 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py @@ -7,6 +7,8 @@ import platform from milc import cli +from qmk.info_json_encoder import InfoJSONEncoder +from qmk.constants import COL_LETTERS, ROW_LETTERS from qmk.decorators import automagic_keyboard, automagic_keymap from qmk.keyboard import render_layouts, render_layout from qmk.keymap import locate_keymap @@ -15,9 +17,6 @@ from qmk.path import is_keyboard platform_id = platform.platform().lower() -ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' -COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' - def show_keymap(kb_info_json, title_caps=True): """Render the keymap in ascii art. @@ -30,7 +29,7 @@ def show_keymap(kb_info_json, title_caps=True): else: cli.echo('{fg_blue}keymap_%s{fg_reset}:', cli.config.info.keymap) - keymap_data = json.load(keymap_path.open()) + keymap_data = json.load(keymap_path.open(encoding='utf-8')) layout_name = keymap_data['layout'] for layer_num, layer in enumerate(keymap_data['layers']): @@ -58,7 +57,7 @@ def show_matrix(kb_info_json, title_caps=True): # Build our label list labels = [] for key in layout['layout']: - if key['matrix']: + if 'matrix' in key: row = ROW_LETTERS[key['matrix'][0]] col = COL_LETTERS[key['matrix'][1]] @@ -92,6 +91,9 @@ def print_friendly_output(kb_info_json): cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (kb_info_json['width'], kb_info_json['height'])) cli.echo('{fg_blue}Processor{fg_reset}: %s', kb_info_json.get('processor', 'Unknown')) cli.echo('{fg_blue}Bootloader{fg_reset}: %s', kb_info_json.get('bootloader', 'Unknown')) + if 'layout_aliases' in kb_info_json: + aliases = [f'{key}={value}' for key, value in kb_info_json['layout_aliases'].items()] + cli.echo('{fg_blue}Layout aliases:{fg_reset} %s' % (', '.join(aliases),)) if cli.config.info.layouts: show_layouts(kb_info_json, True) @@ -149,7 +151,7 @@ def info(cli): # Output in the requested format if cli.args.format == 'json': - print(json.dumps(kb_info_json)) + print(json.dumps(kb_info_json, cls=InfoJSONEncoder)) elif cli.args.format == 'text': print_text_output(kb_info_json) elif cli.args.format == 'friendly': |