mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-10 18:49:08 +00:00
7329c2d02d
* Add initial pass at KLE convert * Add cli log on convert * Move kle2xy, add absolute filepath arg support * Add overwrite flag, and context sensitive conversion * Update docs/cli.md * Fix converter.py typo * Add convert unit test * Rename to kle2qmk * Rename subcommand * Rename subcommand to kle2json * Change tests to cover rename * Rename in __init__.py * Update CLI docs with new subcommand name * Fix from suggestions in PR #6898 * Help with cases of case sensitivity * Update cli.md * Use angle brackets to indicate required option * Make the output text more accurate
33 lines
804 B
Python
33 lines
804 B
Python
"""Functions to convert to and from QMK formats
|
|
"""
|
|
from collections import OrderedDict
|
|
|
|
|
|
def kle2qmk(kle):
|
|
"""Convert a KLE layout to QMK's layout format.
|
|
"""
|
|
layout = []
|
|
|
|
for row in kle:
|
|
for key in row:
|
|
if key['decal']:
|
|
continue
|
|
|
|
qmk_key = OrderedDict(
|
|
label="",
|
|
x=key['column'],
|
|
y=key['row'],
|
|
)
|
|
|
|
if key['width'] != 1:
|
|
qmk_key['w'] = key['width']
|
|
if key['height'] != 1:
|
|
qmk_key['h'] = key['height']
|
|
if 'name' in key and key['name']:
|
|
qmk_key['label'] = key['name'].split('\n', 1)[0]
|
|
else:
|
|
del (qmk_key['label'])
|
|
|
|
layout.append(qmk_key)
|
|
|
|
return layout
|