summaryrefslogtreecommitdiff
path: root/lib/python/qmk/json_encoders.py
diff options
context:
space:
mode:
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):
235 return '01build_targets' 235 return '01build_targets'
236 236
237 return key 237 return key
238
239
240class CommunityModuleJSONEncoder(QMKJSONEncoder):
241 """Custom encoder to make qmk_module.json's a little nicer to work with.
242 """
243 def sort_dict(self, item):
244 """Sorts the hashes in a nice way.
245 """
246 key = item[0]
247
248 if self.indentation_level == 1:
249 if key == 'module_name':
250 return '00module_name'
251 if key == 'maintainer':
252 return '01maintainer'
253 if key == 'url':
254 return '02url'
255 if key == 'features':
256 return '03features'
257 if key == 'keycodes':
258 return '04keycodes'
259 elif self.indentation_level == 3: # keycodes
260 if key == 'key':
261 return '00key'
262 if key == 'aliases':
263 return '01aliases'
264
265 return key