diff options
author | Zach White <skullydazed@gmail.com> | 2020-10-25 14:48:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-25 14:48:44 -0700 |
commit | 0c42f91f4ccf98a37f055afb777ed491da56335e (patch) | |
tree | 547344d80fe7bf75ff3f348eefbc19dbdd346a8a /lib/python/qmk/cli/info.py | |
parent | 8ef82c466e73e555fd74107d4c57e678d7152ecc (diff) | |
download | qmk_firmware-0c42f91f4ccf98a37f055afb777ed491da56335e.tar.gz qmk_firmware-0c42f91f4ccf98a37f055afb777ed491da56335e.zip |
Generate api data on each push (#10609)
* add new qmk generate-api command, to generate a complete set of API data.
* Generate api data and push it to the keyboard repo
* fix typo
* Apply suggestions from code review
Co-authored-by: Joel Challis <git@zvecr.com>
* fixup api workflow
* remove file-changes-action
* use a more mainstream github action
* fix yaml error
* Apply suggestions from code review
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
* more uniform date handling
* make flake8 happy
* Update lib/python/qmk/decorators.py
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'lib/python/qmk/cli/info.py')
-rwxr-xr-x | lib/python/qmk/cli/info.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 0e64d4074..44ce1186a 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py | |||
@@ -16,7 +16,7 @@ ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' | |||
16 | COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' | 16 | COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' |
17 | 17 | ||
18 | 18 | ||
19 | def show_keymap(info_json, title_caps=True): | 19 | def show_keymap(kb_info_json, title_caps=True): |
20 | """Render the keymap in ascii art. | 20 | """Render the keymap in ascii art. |
21 | """ | 21 | """ |
22 | keymap_path = locate_keymap(cli.config.info.keyboard, cli.config.info.keymap) | 22 | keymap_path = locate_keymap(cli.config.info.keyboard, cli.config.info.keymap) |
@@ -36,7 +36,7 @@ def show_keymap(info_json, title_caps=True): | |||
36 | else: | 36 | else: |
37 | cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num) | 37 | cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num) |
38 | 38 | ||
39 | print(render_layout(info_json['layouts'][layout_name]['layout'], layer)) | 39 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], layer)) |
40 | 40 | ||
41 | 41 | ||
42 | def show_layouts(kb_info_json, title_caps=True): | 42 | def show_layouts(kb_info_json, title_caps=True): |
@@ -48,10 +48,10 @@ def show_layouts(kb_info_json, title_caps=True): | |||
48 | print(layout_art) # Avoid passing dirty data to cli.echo() | 48 | print(layout_art) # Avoid passing dirty data to cli.echo() |
49 | 49 | ||
50 | 50 | ||
51 | def show_matrix(info_json, title_caps=True): | 51 | def show_matrix(kb_info_json, title_caps=True): |
52 | """Render the layout with matrix labels in ascii art. | 52 | """Render the layout with matrix labels in ascii art. |
53 | """ | 53 | """ |
54 | for layout_name, layout in info_json['layouts'].items(): | 54 | for layout_name, layout in kb_info_json['layouts'].items(): |
55 | # Build our label list | 55 | # Build our label list |
56 | labels = [] | 56 | labels = [] |
57 | for key in layout['layout']: | 57 | for key in layout['layout']: |
@@ -69,54 +69,54 @@ def show_matrix(info_json, title_caps=True): | |||
69 | else: | 69 | else: |
70 | cli.echo('{fg_blue}matrix_%s{fg_reset}:', layout_name) | 70 | cli.echo('{fg_blue}matrix_%s{fg_reset}:', layout_name) |
71 | 71 | ||
72 | print(render_layout(info_json['layouts'][layout_name]['layout'], labels)) | 72 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], labels)) |
73 | 73 | ||
74 | 74 | ||
75 | def print_friendly_output(info_json): | 75 | def print_friendly_output(kb_info_json): |
76 | """Print the info.json in a friendly text format. | 76 | """Print the info.json in a friendly text format. |
77 | """ | 77 | """ |
78 | cli.echo('{fg_blue}Keyboard Name{fg_reset}: %s', info_json.get('keyboard_name', 'Unknown')) | 78 | cli.echo('{fg_blue}Keyboard Name{fg_reset}: %s', kb_info_json.get('keyboard_name', 'Unknown')) |
79 | cli.echo('{fg_blue}Manufacturer{fg_reset}: %s', info_json.get('manufacturer', 'Unknown')) | 79 | cli.echo('{fg_blue}Manufacturer{fg_reset}: %s', kb_info_json.get('manufacturer', 'Unknown')) |
80 | if 'url' in info_json: | 80 | if 'url' in kb_info_json: |
81 | cli.echo('{fg_blue}Website{fg_reset}: %s', info_json.get('url', '')) | 81 | cli.echo('{fg_blue}Website{fg_reset}: %s', kb_info_json.get('url', '')) |
82 | if info_json.get('maintainer', 'qmk') == 'qmk': | 82 | if kb_info_json.get('maintainer', 'qmk') == 'qmk': |
83 | cli.echo('{fg_blue}Maintainer{fg_reset}: QMK Community') | 83 | cli.echo('{fg_blue}Maintainer{fg_reset}: QMK Community') |
84 | else: | 84 | else: |
85 | cli.echo('{fg_blue}Maintainer{fg_reset}: %s', info_json['maintainer']) | 85 | cli.echo('{fg_blue}Maintainer{fg_reset}: %s', kb_info_json['maintainer']) |
86 | cli.echo('{fg_blue}Keyboard Folder{fg_reset}: %s', info_json.get('keyboard_folder', 'Unknown')) | 86 | cli.echo('{fg_blue}Keyboard Folder{fg_reset}: %s', kb_info_json.get('keyboard_folder', 'Unknown')) |
87 | cli.echo('{fg_blue}Layouts{fg_reset}: %s', ', '.join(sorted(info_json['layouts'].keys()))) | 87 | cli.echo('{fg_blue}Layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys()))) |
88 | if 'width' in info_json and 'height' in info_json: | 88 | if 'width' in kb_info_json and 'height' in kb_info_json: |
89 | cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (info_json['width'], info_json['height'])) | 89 | cli.echo('{fg_blue}Size{fg_reset}: %s x %s' % (kb_info_json['width'], kb_info_json['height'])) |
90 | cli.echo('{fg_blue}Processor{fg_reset}: %s', info_json.get('processor', 'Unknown')) | 90 | cli.echo('{fg_blue}Processor{fg_reset}: %s', kb_info_json.get('processor', 'Unknown')) |
91 | cli.echo('{fg_blue}Bootloader{fg_reset}: %s', info_json.get('bootloader', 'Unknown')) | 91 | cli.echo('{fg_blue}Bootloader{fg_reset}: %s', kb_info_json.get('bootloader', 'Unknown')) |
92 | 92 | ||
93 | if cli.config.info.layouts: | 93 | if cli.config.info.layouts: |
94 | show_layouts(info_json, True) | 94 | show_layouts(kb_info_json, True) |
95 | 95 | ||
96 | if cli.config.info.matrix: | 96 | if cli.config.info.matrix: |
97 | show_matrix(info_json, True) | 97 | show_matrix(kb_info_json, True) |
98 | 98 | ||
99 | if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': | 99 | if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': |
100 | show_keymap(info_json, True) | 100 | show_keymap(kb_info_json, True) |
101 | 101 | ||
102 | 102 | ||
103 | def print_text_output(info_json): | 103 | def print_text_output(kb_info_json): |
104 | """Print the info.json in a plain text format. | 104 | """Print the info.json in a plain text format. |
105 | """ | 105 | """ |
106 | for key in sorted(info_json): | 106 | for key in sorted(kb_info_json): |
107 | if key == 'layouts': | 107 | if key == 'layouts': |
108 | cli.echo('{fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(info_json['layouts'].keys()))) | 108 | cli.echo('{fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys()))) |
109 | else: | 109 | else: |
110 | cli.echo('{fg_blue}%s{fg_reset}: %s', key, info_json[key]) | 110 | cli.echo('{fg_blue}%s{fg_reset}: %s', key, kb_info_json[key]) |
111 | 111 | ||
112 | if cli.config.info.layouts: | 112 | if cli.config.info.layouts: |
113 | show_layouts(info_json, False) | 113 | show_layouts(kb_info_json, False) |
114 | 114 | ||
115 | if cli.config.info.matrix: | 115 | if cli.config.info.matrix: |
116 | show_matrix(info_json, False) | 116 | show_matrix(kb_info_json, False) |
117 | 117 | ||
118 | if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': | 118 | if cli.config_source.info.keymap and cli.config_source.info.keymap != 'config_file': |
119 | show_keymap(info_json, False) | 119 | show_keymap(kb_info_json, False) |
120 | 120 | ||
121 | 121 | ||
122 | @cli.argument('-kb', '--keyboard', help='Keyboard to show info for.') | 122 | @cli.argument('-kb', '--keyboard', help='Keyboard to show info for.') |