diff options
Diffstat (limited to 'lib/python/qmk/json_encoders.py')
-rwxr-xr-x | lib/python/qmk/json_encoders.py | 28 |
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 |