Remove handling of keyboard level keymap templates (#24234)
This commit is contained in:
parent
ca6ba30a72
commit
783f97ff32
@ -125,41 +125,6 @@ def _generate_macros_function(keymap_json):
|
|||||||
return macro_txt
|
return macro_txt
|
||||||
|
|
||||||
|
|
||||||
def template_json(keyboard):
|
|
||||||
"""Returns a `keymap.json` template for a keyboard.
|
|
||||||
|
|
||||||
If a template exists in `keyboards/<keyboard>/templates/keymap.json` that text will be used instead of an empty dictionary.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
keyboard
|
|
||||||
The keyboard to return a template for.
|
|
||||||
"""
|
|
||||||
template_file = Path('keyboards/%s/templates/keymap.json' % keyboard)
|
|
||||||
template = {'keyboard': keyboard}
|
|
||||||
if template_file.exists():
|
|
||||||
template.update(json.load(template_file.open(encoding='utf-8')))
|
|
||||||
|
|
||||||
return template
|
|
||||||
|
|
||||||
|
|
||||||
def template_c(keyboard):
|
|
||||||
"""Returns a `keymap.c` template for a keyboard.
|
|
||||||
|
|
||||||
If a template exists in `keyboards/<keyboard>/templates/keymap.c` that text will be used instead of an empty dictionary.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
keyboard
|
|
||||||
The keyboard to return a template for.
|
|
||||||
"""
|
|
||||||
template_file = Path('keyboards/%s/templates/keymap.c' % keyboard)
|
|
||||||
if template_file.exists():
|
|
||||||
template = template_file.read_text(encoding='utf-8')
|
|
||||||
else:
|
|
||||||
template = DEFAULT_KEYMAP_C
|
|
||||||
|
|
||||||
return template
|
|
||||||
|
|
||||||
|
|
||||||
def _strip_any(keycode):
|
def _strip_any(keycode):
|
||||||
"""Remove ANY() from a keycode.
|
"""Remove ANY() from a keycode.
|
||||||
"""
|
"""
|
||||||
@ -278,7 +243,7 @@ def generate_json(keymap, keyboard, layout, layers, macros=None):
|
|||||||
macros
|
macros
|
||||||
A sequence of strings containing macros to implement for this keyboard.
|
A sequence of strings containing macros to implement for this keyboard.
|
||||||
"""
|
"""
|
||||||
new_keymap = template_json(keyboard)
|
new_keymap = {'keyboard': keyboard}
|
||||||
new_keymap['keymap'] = keymap
|
new_keymap['keymap'] = keymap
|
||||||
new_keymap['layout'] = layout
|
new_keymap['layout'] = layout
|
||||||
new_keymap['layers'] = layers
|
new_keymap['layers'] = layers
|
||||||
@ -305,7 +270,7 @@ def generate_c(keymap_json):
|
|||||||
macros
|
macros
|
||||||
A sequence of strings containing macros to implement for this keyboard.
|
A sequence of strings containing macros to implement for this keyboard.
|
||||||
"""
|
"""
|
||||||
new_keymap = template_c(keymap_json['keyboard'])
|
new_keymap = DEFAULT_KEYMAP_C
|
||||||
layer_txt = _generate_keymap_table(keymap_json)
|
layer_txt = _generate_keymap_table(keymap_json)
|
||||||
keymap = '\n'.join(layer_txt)
|
keymap = '\n'.join(layer_txt)
|
||||||
new_keymap = new_keymap.replace('__KEYMAP_GOES_HERE__', keymap)
|
new_keymap = new_keymap.replace('__KEYMAP_GOES_HERE__', keymap)
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
import qmk.keymap
|
import qmk.keymap
|
||||||
|
|
||||||
|
|
||||||
def test_template_c_pytest_basic():
|
|
||||||
templ = qmk.keymap.template_c('handwired/pytest/basic')
|
|
||||||
assert templ == qmk.keymap.DEFAULT_KEYMAP_C
|
|
||||||
|
|
||||||
|
|
||||||
def test_template_json_pytest_basic():
|
|
||||||
templ = qmk.keymap.template_json('handwired/pytest/basic')
|
|
||||||
assert templ == {'keyboard': 'handwired/pytest/basic'}
|
|
||||||
|
|
||||||
|
|
||||||
def test_generate_c_pytest_basic():
|
def test_generate_c_pytest_basic():
|
||||||
keymap_json = {
|
keymap_json = {
|
||||||
'keyboard': 'handwired/pytest/basic',
|
'keyboard': 'handwired/pytest/basic',
|
||||||
|
Loading…
Reference in New Issue
Block a user