Parser and serializer for Sled, a serialization language for developer-friendly reading and writing
Project description
parsled
Python package for parsing Sled and serializing Python objects as Sled.
Sled is a serialization language for developer-friendly reading and writing.
Parse: Sled to Python dict
To parse Sled into a Python dict, call from_sled().
from parsled import from_sled
with open("path/to/my_file.sled", mode="r") as f:
data = from_sled(f.read())
Serialize: Python to Sled
This package provides 2 ways to serialize Python objects.
- Call
to_sled(). - Instantiate a
SledSerializerand call itsto_sled()method.
Both have the same configuration options and defaults.
For details, refer to the SledSerializer documentation.
Approach #1 simply does approach #2 under the hood. Approach #2 may be useful if you want to set a configuration once and reuse that for serialization multiple times.
from parsled import SledSerializer, to_sled
data = {}
other_data = {}
# Approach #1
sled = to_sled(data)
# Approach #2
sled_serializer = SledSerializer()
sled = sled_serializer.to_sled(data)
other_sled = sled_serializer.to_sled(other_data)
Default serialization
Instances of the following Python data types (on the left) will be serialized as the associated Sled data type (on the right).
None:nilbool:booleanbytes:hexint:integerfloat:floatstr:identity,quote, orconcatMapping[str, Entity]:smapMapping[int, Entity]:imapIterablethat is not aMapping:list- dataclass:
smap
For an object to be serialized as a standalone Sled document,
it should be a Mapping[str, Entity] or dataclass instance,
since the top level of a Sled document is always a smap.
A dataclass instance is implicitly converted into a Mapping
by calling dataclasses.fields() (unless the original instance is itself
also a Mapping, in which case that takes precedence).
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 Distribution
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 parsled-0.2.0.tar.gz.
File metadata
- Download URL: parsled-0.2.0.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d5b3720f6a424f7cad2ab6320c8ed67e822b2c17e009c5e529a17fd30894e7a
|
|
| MD5 |
b9394f2564b55cf657565e125c3f39aa
|
|
| BLAKE2b-256 |
645559065febd1f3c2292f33b0acff5d8bce88ba6b79a8abb8d1d0802bbe9c50
|
File details
Details for the file parsled-0.2.0-py3-none-any.whl.
File metadata
- Download URL: parsled-0.2.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbf329e4a62430b97fb784e5f128fa57ace9f2dec39f06914dda2129bff73227
|
|
| MD5 |
a98c193387e6203c9c2a03b62a9c2659
|
|
| BLAKE2b-256 |
f8476157d1a873aa95b845fb517bf9deb157faf53d02a1cfbf1ecf33f1c29b2d
|