diff --git a/lib/python/qmk/lighting.py b/lib/python/qmk/lighting.py index 2a81cf9e8d7..e88fb21c70b 100644 --- a/lib/python/qmk/lighting.py +++ b/lib/python/qmk/lighting.py @@ -8,10 +8,13 @@ def list_lighting_versions(feature): """Return available versions - sorted newest first """ ret = [] - for file in Path('data/constants/lighting/').glob(f'{feature}_[0-9].[0-9].[0-9].hjson'): - ret.append(file.stem.split('_')[-1]) + for file in Path('data/constants/lighting/').glob(f'{feature}_*.hjson'): + version = file.stem[len(feature) + 1:] + parts = version.split('.') + if len(parts) == 3 and all(part.isascii() and part.isdigit() for part in parts): + ret.append(version) - ret.sort(reverse=True) + ret.sort(key=lambda version: tuple(map(int, version.split('.'))), reverse=True) return ret diff --git a/lib/python/qmk/xap/common.py b/lib/python/qmk/xap/common.py index 03d188804c4..447ca372a26 100755 --- a/lib/python/qmk/xap/common.py +++ b/lib/python/qmk/xap/common.py @@ -78,7 +78,16 @@ def get_xap_definition_files(): """Get the sorted list of XAP definition files, from /data/xap. """ xap_defs = qmk.constants.QMK_FIRMWARE / "data" / "xap" - return list(sorted(xap_defs.glob('**/xap_*.hjson'))) + versions = [] + for file in xap_defs.glob('**/xap_*.hjson'): + version = file.stem[len('xap_'):] + 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: xap_defs / f'xap_{version}.hjson', versions)) def update_xap_definitions(original, new):