Add in some defaults to info.json payload

This commit is contained in:
zvecr 2022-07-07 16:48:18 +01:00
parent a65f6d33f7
commit f913f126b4

View file

@ -2,22 +2,38 @@
""" """
import json import json
import gzip import gzip
from pathlib import Path
from qmk.info import keymap_json from qmk.info import keymap_json
from qmk.commands import get_chunks, dump_lines from qmk.commands import get_chunks, dump_lines
from qmk.json_schema import deep_update, json_load
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
def generate_blob(output_file, keyboard, keymap): def _build_info(keyboard, keymap):
# Build the info.json file """Build the xap version of info.json
"""
defaults_json = json_load(Path('data/mappings/xap_defaults.json'))
km_info_json = keymap_json(keyboard, keymap) km_info_json = keymap_json(keyboard, keymap)
info_json = {}
deep_update(info_json, defaults_json)
deep_update(info_json, km_info_json)
# TODO: Munge to XAP requirements # TODO: Munge to XAP requirements
del km_info_json['config_h_features'] del info_json['config_h_features']
return info_json
def generate_blob(output_file, keyboard, keymap):
"""Generate XAP payload
"""
info_json = _build_info(keyboard, keymap)
# Minify # Minify
str_data = json.dumps(km_info_json, separators=(',', ':')) str_data = json.dumps(info_json, separators=(',', ':'))
# Compress # Compress
compressed = gzip.compress(str_data.encode("utf-8"), compresslevel=9) compressed = gzip.compress(str_data.encode("utf-8"), compresslevel=9)