You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
804 B

  1. """Functions to convert to and from QMK formats
  2. """
  3. from collections import OrderedDict
  4. def kle2qmk(kle):
  5. """Convert a KLE layout to QMK's layout format.
  6. """
  7. layout = []
  8. for row in kle:
  9. for key in row:
  10. if key['decal']:
  11. continue
  12. qmk_key = OrderedDict(
  13. label="",
  14. x=key['column'],
  15. y=key['row'],
  16. )
  17. if key['width'] != 1:
  18. qmk_key['w'] = key['width']
  19. if key['height'] != 1:
  20. qmk_key['h'] = key['height']
  21. if 'name' in key and key['name']:
  22. qmk_key['label'] = key['name'].split('\n', 1)[0]
  23. else:
  24. del (qmk_key['label'])
  25. layout.append(qmk_key)
  26. return layout