mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-10-22 00:42:47 +02:00
Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
@@ -11,6 +11,8 @@ from qmk.constants import QMK_FIRMWARE, QMK_USERSPACE, HAS_QMK_USERSPACE
|
||||
from qmk.path import under_qmk_firmware, under_qmk_userspace
|
||||
|
||||
COMMUNITY_MODULE_JSON_FILENAME = 'qmk_module.json'
|
||||
CONSTANTS_PATH = Path('data/constants/')
|
||||
HOOKS_PATH = CONSTANTS_PATH / 'module_hooks'
|
||||
|
||||
|
||||
class ModuleAPI(AttrDict):
|
||||
@@ -20,9 +22,23 @@ class ModuleAPI(AttrDict):
|
||||
self[key] = value
|
||||
|
||||
|
||||
def _list_module_files():
|
||||
versions = []
|
||||
module_definition_files = HOOKS_PATH.glob('*.hjson')
|
||||
for file in module_definition_files:
|
||||
version = file.stem
|
||||
parts = version.split('.')
|
||||
if len(parts) == 3 and all(part.isascii() and part.isdigit() for part in parts):
|
||||
versions.append(version)
|
||||
|
||||
versions.sort(key=lambda version: tuple(map(int, version.split('.'))))
|
||||
|
||||
return list(map(lambda version: HOOKS_PATH / f'{version}.hjson', versions))
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def module_api_list():
|
||||
module_definition_files = sorted(set(QMK_FIRMWARE.glob('data/constants/module_hooks/*.hjson')))
|
||||
module_definition_files = _list_module_files()
|
||||
module_definition_jsons = [json_load(f) for f in module_definition_files]
|
||||
module_definitions = merge_ordered_dicts(module_definition_jsons)
|
||||
latest_module_version = module_definition_files[-1].stem
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
|
||||
from qmk import community_modules
|
||||
|
||||
|
||||
def test_list_supports_multi_digit_patch_versions():
|
||||
with TemporaryDirectory() as temporary:
|
||||
path = Path(temporary)
|
||||
(path / '0.0.9.hjson').write_text('{}')
|
||||
(path / '0.0.10.hjson').write_text('{}')
|
||||
|
||||
with patch.object(community_modules, 'HOOKS_PATH', path):
|
||||
_data, version, _minor, _major, _patch = community_modules.module_api_list()
|
||||
assert version == '0.0.10'
|
||||
Reference in New Issue
Block a user