pykelet
JSON-safe metadata blocks for Python scripts and HTML — parsed by humans and machines alike.
Pykelet gives you one canonical place per file to declare what it is, what it expects, and what it produces.
- HTML files — a
<!--PYKELET ... -->comment block placed right after<!DOCTYPE html>. Read by the browser (viapykelet.js) and by Python. - Python scripts — a module-level
PYKELET = {...}dict, read via AST (the script's main body is never executed during discovery).
Pulling data from an HTML comment
A Pykelet front matter block is essentially the same as that of a YAML
Jekyll/Hugo front matter block except that we encase it in an HTML comment
<!-- ... --> rather than YAML --- ... ---.
The aim is to be able to pull information from a source-code style comment. This is not intended for SEO purposes (comments are generally no longer indexed by search bots), so such data should still be put in the header if required.
Example
<!--PYKELET
FILENAME: example.html
DESCRIPTION: This is a demonstration HTML file showing metadata extraction.
AUTHOR: Andrew Kingdom
LICENSE: BSD 3-Clause
-->
into this:
FILENAME: example.html DESCRIPTION: This is a demonstration HTML file showing metadata extraction. AUTHOR: Andrew Kingdom LICENSE: BSD 3-Clause
Browser usage
Include pykelet.js as early as possible in <head>:
<!DOCTYPE html>
<!--PYKELET
TITLE: My Page
AUTHOR: Jane Doe
-->
<html>
<head>
<script src="js/pykelet.js"></script>
</head>
<body>
<h1 id="TITLE"></h1>
</body>
</html>
pykelet.js populates document.pykelet.comment and auto-fills any element
whose id matches a key. Disable auto-fill by defining
const disabled_fillDocumentFromPykeletComments = true; before the script
loads.
Python usage
Python script with inline PYKELET
from pykelet import true, false, null
PYKELET = {
"name": "my_op",
"description": "Adds two numbers.",
"version": "1.0.0",
"timeout": 30,
"active": true,
"parent": null,
"input_schema": {"type": "object",
"properties": {"a": {"type": "number"},
"b": {"type": "number"}}},
"output_schema": {"type": "object",
"properties": {"sum": {"type": "number"}}},
}
Parse HTML or Python
from pykelet import parse_file
meta = parse_file("example.html") # → {"FILENAME": ..., ...}
meta = parse_file("my_script.py") # → {"name": "my_op", ...}
Fill HTML server-side
from pykelet import fill_html
html = open("example.html").read()
filled = fill_html(html, {}, parse=True) # elements with matching ids filled
Bundled JS
The JS ships inside the package. Extract it with:
from pykelet import copy_js
copy_js("static/") # → static/pykelet.js
Or from the shell:
pykelet copy-js static/
pykelet print-js > static/pykelet.js
CLI
pykelet inspect example.html
pykelet inspect my_script.py
pykelet fill example.html out.html
pykelet copy-js static/
Install
pip install pykelet
Roadmap
- Pykelet comment blocks are part of a larger yet-to-be-released system.
- YAML: For certain file formats (e.g. .llux, etc.) YAML might be used.
License
BSD 3-Clause. See LICENSE.md.
Metadata
Release files for pykelet 2.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pykelet-2.0.6.tar.gz | 12.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pykelet-2.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.6 kB
Release files / pykelet-2.0.6.tar.gz
| Download URL | pykelet-2.0.6.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
447e99b12240772b5491fe00df8d3509bacf61c10af924e8ec98ef0cd908ce39
|
|
BLAKE2b-256 checksum How to use checksums |
2be2ae2d56e81d17081fced1dd85d634c548f4a6abe2bc38013e29f9470c97b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / pykelet-2.0.6-py3-none-any.whl
| Download URL | pykelet-2.0.6-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45a3d37783cacd34b778ed5138990bf7fee26ffe204b3dbdd2433f6eea34d7d1
|
|
BLAKE2b-256 checksum How to use checksums |
e430b7314ec839d14884d2508a13a673031e7dd406091a62d097b990df30ca61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for pykelet 2.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.