kle-scraper


Namekle-scraper JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
Summarykle-scraper is a Python library for scraping the key top images of keyboard-layout-editor.com (KLE).
upload_time2025-01-29 00:38:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License Copyright (c) 2021-2025 NAKAZATO Hajime Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords keyboard-layout-editor.com kle
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # kle-scraper

**kle-scraper** is a Python library for scraping the key top images of 
[keyboard-layout-editor.com (KLE)](http://www.keyboard-layout-editor.com/).

It renders KLE screen by CEF (Chromium Embedded Framework) and captures it. 
It contains KLE codes and works offline, of course.

## Limitations

- No support for custom styles. Key color is always white.
- Front legend is ignored.
- Legend color is equal to KLE screen, not the value in properties. KLE screen color is 
a bit paler than the value in properties.
- It handles non-rectangle keys (big ass enter and ISO enter) awkwardly. Big ass enter image 
lacks the left bottom bulge and ISO enter contains the left bottom dent.
- Crop area isn't pixel-wise precise, especially about rotated keys. The precision is half pixel 
in KLE screen.
- It is non-reentrant (not multi-threaded).
- It is slow, especially when the layout has a lot of differently rotated keys.
- It cannot handle extraordinary large layout.

Available platforms:

- Windows x86-64
- macOS Intel and Apple Silicon
- Linux x86-64 (aarch64 has a problem now in CEF. See: [Dynamic loading of libcef.so on Linux ARM64 not possible anymore due to TLS size increase](https://github.com/chromiumembedded/cef/issues/3803))

## Installation

Grab your platform's wheel from [cef-capi-py release](https://github.com/hajimen/cef-capi-py/releases/tag/131.3.5) and `pip install` it.
I haven't uploaded the wheels to PyPI yet because now PyPI project is not processing support issues:
[File Limit Request: cef-capi-py - 180 MB](https://github.com/pypi/support/issues/5491).

```bash
pip install kle-scraper
```

## Usage

```python
import tempfile
from kle_scraper import scrape

with tempfile.TemporaryDirectory() as image_output_dir:
    keyboard = scrape(kle_json_filename, image_output_dir)
```

You can find `0.png`, `1.png` and more in `image_output_dir`. The filename number corresponds to 
`keyboard.keys`'s index. `keyboard` is an instance of `pykle_serial.Keyboard`.

Otherwise from command line,

```bash
python -m kle_scraper {kle_json_filename} {image_output_dir}
```

## Dimension of scraped images

Scraped images are magnified to 4x. On KLE screen, 1u key top has 42x42 px. 
Key layout pitch is 54x54 px. On scraped images, 1u key top (and image size) is 
168x168 px and 1u pitch is 216x216 px.

## License

MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "kle-scraper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "keyboard-layout-editor.com, KLE",
    "author": null,
    "author_email": "NAKAZATO Hajime <hajime@kaoriha.org>",
    "download_url": null,
    "platform": null,
    "description": "# kle-scraper\r\n\r\n**kle-scraper** is a Python library for scraping the key top images of \r\n[keyboard-layout-editor.com (KLE)](http://www.keyboard-layout-editor.com/).\r\n\r\nIt renders KLE screen by CEF (Chromium Embedded Framework) and captures it. \r\nIt contains KLE codes and works offline, of course.\r\n\r\n## Limitations\r\n\r\n- No support for custom styles. Key color is always white.\r\n- Front legend is ignored.\r\n- Legend color is equal to KLE screen, not the value in properties. KLE screen color is \r\na bit paler than the value in properties.\r\n- It handles non-rectangle keys (big ass enter and ISO enter) awkwardly. Big ass enter image \r\nlacks the left bottom bulge and ISO enter contains the left bottom dent.\r\n- Crop area isn't pixel-wise precise, especially about rotated keys. The precision is half pixel \r\nin KLE screen.\r\n- It is non-reentrant (not multi-threaded).\r\n- It is slow, especially when the layout has a lot of differently rotated keys.\r\n- It cannot handle extraordinary large layout.\r\n\r\nAvailable platforms:\r\n\r\n- Windows x86-64\r\n- macOS Intel and Apple Silicon\r\n- Linux x86-64 (aarch64 has a problem now in CEF. See: [Dynamic loading of libcef.so on Linux ARM64 not possible anymore due to TLS size increase](https://github.com/chromiumembedded/cef/issues/3803))\r\n\r\n## Installation\r\n\r\nGrab your platform's wheel from [cef-capi-py release](https://github.com/hajimen/cef-capi-py/releases/tag/131.3.5) and `pip install` it.\r\nI haven't uploaded the wheels to PyPI yet because now PyPI project is not processing support issues:\r\n[File Limit Request: cef-capi-py - 180 MB](https://github.com/pypi/support/issues/5491).\r\n\r\n```bash\r\npip install kle-scraper\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nimport tempfile\r\nfrom kle_scraper import scrape\r\n\r\nwith tempfile.TemporaryDirectory() as image_output_dir:\r\n    keyboard = scrape(kle_json_filename, image_output_dir)\r\n```\r\n\r\nYou can find `0.png`, `1.png` and more in `image_output_dir`. The filename number corresponds to \r\n`keyboard.keys`'s index. `keyboard` is an instance of `pykle_serial.Keyboard`.\r\n\r\nOtherwise from command line,\r\n\r\n```bash\r\npython -m kle_scraper {kle_json_filename} {image_output_dir}\r\n```\r\n\r\n## Dimension of scraped images\r\n\r\nScraped images are magnified to 4x. On KLE screen, 1u key top has 42x42 px. \r\nKey layout pitch is 54x54 px. On scraped images, 1u key top (and image size) is \r\n168x168 px and 1u pitch is 216x216 px.\r\n\r\n## License\r\n\r\nMIT license.\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021-2025 NAKAZATO Hajime  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "kle-scraper is a Python library for scraping the key top images of keyboard-layout-editor.com (KLE).",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/hajimen/kle_scraper/issues",
        "Changelog": "https://github.com/hajimen/kle_scraper/blob/master/CHANGELOG.md",
        "Repository": "https://github.com/hajimen/kle_scraper.git"
    },
    "split_keywords": [
        "keyboard-layout-editor.com",
        " kle"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d304a3d095508bc4f6573372852fdf312ff6c91ff91313eb7e2fed9430d3ba72",
                "md5": "7e5891abaa3510a29a92fe40a1199288",
                "sha256": "844969d693dcccc434b053d099dc870367e50ab9a2d6b54501300cecd6b1f297"
            },
            "downloads": -1,
            "filename": "kle_scraper-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e5891abaa3510a29a92fe40a1199288",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 648950,
            "upload_time": "2025-01-29T00:38:05",
            "upload_time_iso_8601": "2025-01-29T00:38:05.285743Z",
            "url": "https://files.pythonhosted.org/packages/d3/04/a3d095508bc4f6573372852fdf312ff6c91ff91313eb7e2fed9430d3ba72/kle_scraper-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-29 00:38:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hajimen",
    "github_project": "kle_scraper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "kle-scraper"
}
        
Elapsed time: 0.53621s