/pykle_serial

A Python library for parsing the serialized format used on keyboard-layout-editor.com (KLE).

Primary LanguagePythonMIT LicenseMIT

pykle_serial

pykle_serial is a Python library for parsing the serialized format used on keyboard-layout-editor.com (KLE). pykle_serial is a Python port of kle-serial, based on commit #4080386 on Dec 31, 2019 and includes Fix issue with incorrect x and y for rotated key.

Usage

import pykle_serial as kle_serial

keyboard = kle_serial.deserialize([
    {'name': "Sample", 'author': "Your Name"},
    ["Q", "W", "E", "R", "T", "Y"]
])

# or

keyboard = kle_serial.parse('''[
    { name: "Sample", author: "Your Name" },
    ["Q", "W", "E", "R", "T", "Y"]
]''')

About the details of keyboard, see original kle-serial.

Noticeable differences from original kle-serial

  • labels / textColor / textSize of Key class always have 12 elements.

JavaScript's array esoterically supports out-of-index access. Python's list doesn't.

  • (implicit) textSize is int.

JavaScript doesn't distinguish between float and int. Python does.

Caveats

  • KLE's "Raw data" text requires additional outer [] as JSON5.

  • labels is HTML fragment.