aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/json_encoders.py
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2025-02-26 22:25:41 +1100
committerGitHub <[email protected]>2025-02-26 22:25:41 +1100
commit1efc82403bebe759272d1ba7a79d9dfa0d5df506 (patch)
treec356ae7afeb0849926534beb5dd4515f693abf99 /lib/python/qmk/json_encoders.py
parent63b095212b157c4522bdeda3de144fb87213085d (diff)
downloadqmk_firmware-1efc82403bebe759272d1ba7a79d9dfa0d5df506.tar.gz
qmk_firmware-1efc82403bebe759272d1ba7a79d9dfa0d5df506.zip
Community modules (#24848)
Diffstat (limited to 'lib/python/qmk/json_encoders.py')
-rwxr-xr-xlib/python/qmk/json_encoders.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/python/qmk/json_encoders.py b/lib/python/qmk/json_encoders.py
index 0e4ad1d220..e83a381d52 100755
--- a/lib/python/qmk/json_encoders.py
+++ b/lib/python/qmk/json_encoders.py
@@ -235,3 +235,31 @@ class UserspaceJSONEncoder(QMKJSONEncoder):
return '01build_targets'
return key
+
+
+class CommunityModuleJSONEncoder(QMKJSONEncoder):
+ """Custom encoder to make qmk_module.json's a little nicer to work with.
+ """
+ def sort_dict(self, item):
+ """Sorts the hashes in a nice way.
+ """
+ key = item[0]
+
+ if self.indentation_level == 1:
+ if key == 'module_name':
+ return '00module_name'
+ if key == 'maintainer':
+ return '01maintainer'
+ if key == 'url':
+ return '02url'
+ if key == 'features':
+ return '03features'
+ if key == 'keycodes':
+ return '04keycodes'
+ elif self.indentation_level == 3: # keycodes
+ if key == 'key':
+ return '00key'
+ if key == 'aliases':
+ return '01aliases'
+
+ return key