1
0
Fork 0

Reallocate user/kb keycode ranges (#19907)

This commit is contained in:
Joel Challis 2023-02-22 22:50:09 +00:00 committed by GitHub
parent 961f0b7b2d
commit 9f2cd9119f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 69 deletions

View file

@ -107,6 +107,7 @@ def deep_update(origdict, newdict):
def merge_ordered_dicts(dicts):
"""Merges nested OrderedDict objects resulting from reading a hjson file.
Later input dicts overrides earlier dicts for plain values.
If any value is "!delete!", the existing value will be removed from its parent.
Arrays will be appended. If the first entry of an array is "!reset!", the contents of the array will be cleared and replaced with RHS.
Dictionaries will be recursively merged. If any entry is "!reset!", the contents of the dictionary will be cleared and replaced with RHS.
"""
@ -125,6 +126,8 @@ def merge_ordered_dicts(dicts):
target[k] = v[1:]
else:
target[k] = target[k] + v
elif v == "!delete!" and isinstance(target, (OrderedDict, dict)):
del target[k]
else:
target[k] = v

View file

@ -90,6 +90,7 @@ def load_spec(version, lang=None):
# Sort?
spec['keycodes'] = dict(sorted(spec.get('keycodes', {}).items()))
spec['ranges'] = dict(sorted(spec.get('ranges', {}).items()))
# Validate?
_validate(spec)