nyx-lang
A small, dependency-free Python parser and converter for the Nyx 0.1.2 data serialization language.
Nyx is a flat, context-stateful format built around boxes, items, sub-items,
pieces, and tape seals. It maps cleanly to JSON while keeping authoring
readable for nested personal data.
Installation
pip install nyx-lang
Quick Start
import nyx_lang
source = """
^nyx=0.1.2
box: "Inventory"
sub-box: "Electronics"
item: "Console"
sub-item: "manufacturer"
sub-item: "Nintendo"
tape
sub-item: "controllers"
piece: "Pro Controller"
piece: "Joy-Con"
"""
data = nyx_lang.parse(source)
print(nyx_lang.to_json(data))
Output:
{
"Inventory": {
"Electronics": {
"Console": {
"manufacturer": "Nintendo",
"controllers": [
"Pro Controller",
"Joy-Con"
]
}
}
}
}
Command Line
The package installs a nyx command. You can also run it as a module with
python -m nyx_lang.
# Nyx -> JSON
nyx to-json input.nyx --output output.json
python -m nyx_lang to-json input.nyx --output output.json
# JSON -> Nyx
nyx to-nyx input.json --output output.nyx
python -m nyx_lang to-nyx input.json --output output.nyx
# Print parsed JSON to the terminal
nyx parse input.nyx
# Validate a Nyx document
nyx validate input.nyx
On Windows, prefer --output over shell redirection so files are written as
UTF-8.
API
nyx_lang.parse(source, *, strict=True) -> dict
Parse a Nyx document string into a Python dictionary.
from nyx_lang import parse
data = parse('^nyx=0.1.2\nbox: "Settings"\nitem: "theme"\nsub-item: "dark"')
assert data == {"Settings": {"theme": "dark"}}
strict=True raises NyxSyntaxError for unsupported versions. Version 0.1
documents are accepted for compatibility with earlier package builds.
nyx_lang.to_json(data, *, indent=2, **kwargs) -> str
Serialize parsed Nyx data to JSON. Extra keyword arguments are passed to
json.dumps.
from nyx_lang import to_json
print(to_json({"Settings": {"theme": "dark"}}, indent=2))
nyx_lang.to_nyx(data) -> str
Serialize a Python dictionary to a Nyx 0.1.2 document.
from nyx_lang import to_nyx
print(to_nyx({"Settings": {"theme": "dark"}}))
Nyx Primer
Every document starts with a version header:
^nyx=0.1.2
Core statements:
| Keyword | Effect |
|---|---|
box: "Name" |
Open a root container. |
sub-box: "Name" |
Open a nested container inside the active box. |
sub-box: "" |
Open the next anonymous array-object slot. |
item: "Name" |
Create an item in the active box. |
sub-item: "key" |
Add a child key under the active item. |
piece: value |
Append a scalar element to the active item list. |
tape |
Seal the current context and step up one level. |
Primitive values:
sub-item: "string"
sub-item: 42
sub-item: 3.14
sub-item: true
sub-item: false
sub-item: null
A sub-item with exactly one scalar child collapses to a key-value pair:
sub-item: "temperature"
sub-item: -4.5
Result:
{ "temperature": -4.5 }
Flat arrays use piece:
item: "controllers"
piece: "Pro Controller"
piece: "Joy-Con"
Arrays of objects use anonymous sub-boxes:
box: "tabs"
sub-box: ""
item: "pageTitle"
sub-item: "Home"
tape
tape
sub-box: ""
item: "pageTitle"
sub-item: "Settings"
Result:
{
"tabs": [
{ "pageTitle": "Home" },
{ "pageTitle": "Settings" }
]
}
Exceptions
| Exception | When raised |
|---|---|
NyxSyntaxError |
Invalid syntax, invalid keyword, missing header, wrong context, or mixed item/list usage. |
NyxVersionWarning |
Unsupported version in lenient mode. |
Development
python -m pip install -e ".[dev]"
python -m pytest
python -m build
Build artifacts are written to dist/.
Publishing Checklist
- Confirm
pyproject.tomlhas the intended version. - Run
python -m pytest. - Run
python -m build. - Inspect the wheel and source distribution in
dist/. - Upload to TestPyPI first:
python -m twine upload --repository testpypi dist/*
- Upload to PyPI:
python -m twine upload dist/*
License
Proprietary. See LICENSE for details.
Metadata
Release files for nyx-lang 0.1.5
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 | Actions |
|---|---|---|---|---|
| nyx_lang-0.1.5.tar.gz | 13.7 kB | Without provenance | Details for nyx_lang-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nyx_lang-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for nyx_lang-0.1.5-py3-none-any.whl |
Total release size: 26.0 kB
Release files / nyx_lang-0.1.5.tar.gz
| Download URL | nyx_lang-0.1.5.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3d758fdf9049dde1e031a4aa52c18cfd2cb2bdf1b9d173210832c9cae3d3a78
|
|
BLAKE2b-256 checksum How to use checksums |
cf16320436282a21b07ae0642f0f45b6d1059d6c543b84bcf11b9a509d9713fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.14
|
Release files / nyx_lang-0.1.5-py3-none-any.whl
| Download URL | nyx_lang-0.1.5-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc0ebb931f0871c7d084de50d6121dac42471c8e1c97023725742ef96cd865fc
|
|
BLAKE2b-256 checksum How to use checksums |
27840aec089466ecd585b06001fc3e95e15920b7da7cba288d6fff76373da2ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.14
|
Security for nyx-lang 0.1.5
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.