Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/python/qmk/cli/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
def _list_defaultish_keymaps(kb):
"""Return default like keymaps for a given keyboard
"""
defaultish = ['ansi', 'iso']
keymaps = set(list_keymaps(kb, include_userspace=False, include_community=False))

# This is only here to flag it as "testable", so it doesn't fly under the radar during PR
defaultish.extend(INVALID_KM_NAMES)

keymaps = set()
for x in list_keymaps(kb, include_userspace=False):
if x in defaultish or x.startswith('default'):
keymaps.add(x)
# Ensure that at least a 'default' keymap always exists
keymaps.add('default')

return keymaps

Expand Down Expand Up @@ -360,6 +355,11 @@ def lint(cli):
cli.print_help()
return False

# milc config handling of user.keymap breaks running lint without keymap argument
# so we have to disable that while still allowing a default to be set with lint.keymap
if 'keymap' not in cli.config_source.lint.keys() and cli.config.lint.keymap:
cli.config.lint.keymap = None

if isinstance(cli.config.lint.keyboard, str):
# if provided via config - string not array
keyboard_list = [cli.config.lint.keyboard]
Expand All @@ -375,12 +375,12 @@ def lint(cli):
# Determine keymaps to also check
if cli.args.keymap == 'all':
keymaps = list_keymaps(kb)
elif cli.args.keymap:
keymaps = {cli.args.keymap}
elif cli.config.lint.keymap:
keymaps = {cli.config.lint.keymap}
else:
keymaps = _list_defaultish_keymaps(kb)
# Ensure that at least a 'default' keymap always exists
keymaps.add('default')

ok = True

Expand Down
36 changes: 20 additions & 16 deletions lib/python/qmk/keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def is_keymap_target(keyboard, keymap):
return False


def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True):
def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True, include_community=True):
"""List the available keymaps for a keyboard.

Args:
Expand All @@ -403,6 +403,9 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
include_userspace
When set to True, also search userspace for available keymaps

include_community
When set to True, also search community layouts folder for available keymaps

Returns:
a sorted list of valid keymap names.
"""
Expand All @@ -426,21 +429,22 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa

kb_path = kb_path.parent

# Check community layouts as a fallback
info = info_json(keyboard)

community_parents = list(Path('layouts').glob('*/'))
if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists():
community_parents.append(Path(QMK_USERSPACE) / "layouts")

for community_parent in community_parents:
for layout in info.get("community_layouts", []):
cl_path = community_parent / layout
if cl_path.is_dir():
for keymap in cl_path.iterdir():
if is_keymap_dir(keymap, c, json, additional_files):
keymap = keymap if fullpath else keymap.name
names.add(keymap)
if include_community:
# Check community layouts as a fallback
info = info_json(keyboard)

community_parents = list(Path('layouts').glob('*/'))
if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists():
community_parents.append(Path(QMK_USERSPACE) / "layouts")

for community_parent in community_parents:
for layout in info.get("community_layouts", []):
cl_path = community_parent / layout
if cl_path.is_dir():
for keymap in cl_path.iterdir():
if is_keymap_dir(keymap, c, json, additional_files):
keymap = keymap if fullpath else keymap.name
names.add(keymap)

return sorted(names)

Expand Down