forked from mirror/qmk_firmware
Remove unused qmk.keymap.write_file/qmk.keymap.write_json (#25854)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"""Functions that help you work with QMK keymaps.
|
"""Functions that help you work with QMK keymaps.
|
||||||
"""
|
"""
|
||||||
import json
|
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import DEVNULL
|
from subprocess import DEVNULL
|
||||||
@@ -320,40 +319,6 @@ def generate_c(keymap_json):
|
|||||||
return new_keymap
|
return new_keymap
|
||||||
|
|
||||||
|
|
||||||
def write_file(keymap_filename, keymap_content):
|
|
||||||
keymap_filename.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
keymap_filename.write_text(keymap_content)
|
|
||||||
|
|
||||||
cli.log.info('Wrote keymap to {fg_cyan}%s', keymap_filename)
|
|
||||||
|
|
||||||
return keymap_filename
|
|
||||||
|
|
||||||
|
|
||||||
def write_json(keyboard, keymap, layout, layers, macros=None):
|
|
||||||
"""Generate the `keymap.json` and write it to disk.
|
|
||||||
|
|
||||||
Returns the filename written to.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
keyboard
|
|
||||||
The name of the keyboard
|
|
||||||
|
|
||||||
keymap
|
|
||||||
The name of the keymap
|
|
||||||
|
|
||||||
layout
|
|
||||||
The LAYOUT macro this keymap uses.
|
|
||||||
|
|
||||||
layers
|
|
||||||
An array of arrays describing the keymap. Each item in the inner array should be a string that is a valid QMK keycode.
|
|
||||||
"""
|
|
||||||
keymap_json = generate_json(keyboard, keymap, layout, layers, macros=None)
|
|
||||||
keymap_content = json.dumps(keymap_json)
|
|
||||||
keymap_file = qmk.path.keymaps(keyboard)[0] / keymap / 'keymap.json'
|
|
||||||
|
|
||||||
return write_file(keymap_file, keymap_content)
|
|
||||||
|
|
||||||
|
|
||||||
def locate_keymap(keyboard, keymap, force_layout=None):
|
def locate_keymap(keyboard, keymap, force_layout=None):
|
||||||
"""Returns the path to a keymap for a specific keyboard.
|
"""Returns the path to a keymap for a specific keyboard.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -42,6 +42,3 @@ def test_generate_json_pytest_basic():
|
|||||||
def test_parse_keymap_c():
|
def test_parse_keymap_c():
|
||||||
parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/pytest/basic/keymaps/default/keymap.c')
|
parsed_keymap_c = qmk.keymap.parse_keymap_c('keyboards/handwired/pytest/basic/keymaps/default/keymap.c')
|
||||||
assert parsed_keymap_c == {'layers': [{'name': '0', 'layout': 'LAYOUT_ortho_1x1', 'keycodes': ['KC_A']}]}
|
assert parsed_keymap_c == {'layers': [{'name': '0', 'layout': 'LAYOUT_ortho_1x1', 'keycodes': ['KC_A']}]}
|
||||||
|
|
||||||
|
|
||||||
# FIXME(skullydazed): Add a test for qmk.keymap.write that mocks up an FD.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user