Selene Data Format v1.0 — parser, validator, and converter
Project description
selene-fmt
Python implementation of the Selene Data Format v1.0 — a compact, human-readable serialization format for configuration files and data interchange.
Install
pip install selene-fmt
Format overview
__sel_v1__
users [
{ name: "Rick" age: 43 }
{ name: "Sam" age: 56 }
]
products [
{ name: "Laptop" price: 999.99 }
{ name: "Mouse" price: 19.5 }
]
key: valueeverywhere — no exceptions{ }delimits records,[ ]delimits blocks- Strings must be double-quoted
- Unquoted tokens: numbers,
true,false,nullonly #comments- Duplicate keys within a record are an error
Python API
import selene
# Parse
data = selene.loads(text) # str → dict
data = selene.load(fp) # file → dict
# Serialize
text = selene.dumps(data) # dict → str
selene.dump(data, fp) # dict → file
# Validate
selene.validate(text) # raises SeleneError on failure
# Convert
json_str = selene.to_json(text, indent=2) # Selene → JSON
sel_str = selene.from_json(json_str) # JSON → Selene
Example
import selene
src = """
__sel_v1__
users [
{ name: "Rick" age: 43 }
{ name: "Sam" age: 56 }
]
"""
data = selene.loads(src)
# {'users': [{'name': 'Rick', 'age': 43}, {'name': 'Sam', 'age': 56}]}
print(selene.to_json(src, indent=2))
# {
# "users": [
# {"name": "Rick", "age": 43},
# {"name": "Sam", "age": 56}
# ]
# }
Errors
All errors raise selene.SeleneError with a descriptive message including the line number:
try:
selene.loads(bad_input)
except selene.SeleneError as e:
print(e) # Line 4: duplicate key 'name' in record
CLI
# Validate a Selene file
selene validate myfile.sel
# Convert Selene → JSON
selene to-json myfile.sel --indent 2
# Convert JSON → Selene
selene from-json myfile.json --indent 4
Nested objects
src = """
__sel_v1__
users [
{
name: "Rick"
age: 43
address: { city: "London" zip: "12345" }
}
]
"""
data = selene.loads(src)
# data['users'][0]['address'] == {'city': 'London', 'zip': '12345'}
License
SOCL
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file selene_fmt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: selene_fmt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04b4c8f16cdd346236b943952da8d19dc5c20a835a83dad83091a61846400c80
|
|
| MD5 |
872d27b0ab024c3a188c0ae5e1d6e5d8
|
|
| BLAKE2b-256 |
577346462eaa22296ece18f07f64d1ecb576e0f17171ca2410d4e9293d5c000e
|