summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/generate/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/generate/api.py')
-rwxr-xr-xlib/python/qmk/cli/generate/api.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py
index 66db37cb52..6d111f244c 100755
--- a/lib/python/qmk/cli/generate/api.py
+++ b/lib/python/qmk/cli/generate/api.py
@@ -8,6 +8,7 @@ from milc import cli
from qmk.datetime import current_datetime
from qmk.info import info_json
+from qmk.info_json_encoder import InfoJSONEncoder
from qmk.keyboard import list_keyboards
@@ -44,15 +45,16 @@ def generate_api(cli):
if 'usb' in kb_all['keyboards'][keyboard_name]:
usb = kb_all['keyboards'][keyboard_name]['usb']
- if usb['vid'] not in usb_list['devices']:
+ if 'vid' in usb and usb['vid'] not in usb_list['devices']:
usb_list['devices'][usb['vid']] = {}
- if usb['pid'] not in usb_list['devices'][usb['vid']]:
+ if 'pid' in usb and usb['pid'] not in usb_list['devices'][usb['vid']]:
usb_list['devices'][usb['vid']][usb['pid']] = {}
- usb_list['devices'][usb['vid']][usb['pid']][keyboard_name] = usb
+ if 'vid' in usb and 'pid' in usb:
+ usb_list['devices'][usb['vid']][usb['pid']][keyboard_name] = usb
# Write the global JSON files
- keyboard_list.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': sorted(kb_all['keyboards'])}))
- keyboard_all.write_text(json.dumps(kb_all))
- usb_file.write_text(json.dumps(usb_list))
+ keyboard_list.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': sorted(kb_all['keyboards'])}, cls=InfoJSONEncoder))
+ keyboard_all.write_text(json.dumps(kb_all, cls=InfoJSONEncoder))
+ usb_file.write_text(json.dumps(usb_list, cls=InfoJSONEncoder))