Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimen committed Dec 16, 2020
1 parent b520d89 commit 7d7e469
Show file tree
Hide file tree
Showing 9 changed files with 912 additions and 0 deletions.
141 changes: 141 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# https://github.com/github/gitignore/commit/14f8a8b4c51ecc00b18905a95c117954e6c77b9d modified
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

.vscode
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## Initial Release: Version 0.0.1 : 2020/12/16

Ported from [commit #4080386 on Dec 31, 2019](https://github.com/ijprest/kle-serial/commit/4080386fcdcb66a391e1b4857532512f9ca4121e).
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# pykle_serial

pykle_serial is a Python library for parsing the serialized format used on [keyboard-layout-editor.com (KLE)](http://www.keyboard-layout-editor.com/).
pykle_serial is a Python port of [kle-serial](https://github.com/ijprest/kle-serial),
based on [commit #4080386 on Dec 31, 2019](https://github.com/ijprest/kle-serial/commit/4080386fcdcb66a391e1b4857532512f9ca4121e).

## Usage

```
from pykle_serial import serial
keyboard = serial.deserialize([
{'name': "Sample", 'author': "Your Name"},
["Q", "W", "E", "R", "T", "Y"]
])
# or
keyboard = serial.parse('''[
{ name: "Sample", author: "Your Name" },
["Q", "W", "E", "R", "T", "Y"]
]''')
```

About the details of `keyboard`, see original [kle-serial](https://github.com/ijprest/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 requies additional outer `[]` as JSON5.

- `labels` is HTML fragment.
2 changes: 2 additions & 0 deletions pykle_serial/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version_info__ = (0, 0, 1)
__version__ = '.'.join(map(str, __version_info__))
Loading

0 comments on commit 7d7e469

Please sign in to comment.