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.
Setup
parsled is available on PyPI.
You can install it using your preferred Python package manager.
For example:
pip install parsled
Parse: Sled to Python dict
To parse a str of Sled into a Python dict, call from_sled().
sled_text = '''
name = "John Doe"
age = 50
children = [Jack ; Jill]
'''
data = parsled.from_sled(sled_text)
assert data == {
"name": "John Doe",
"age": 50,
"children": ["Jack", "Jill"],
}
To parse a Sled file, read it to a str, then pass that into from_sled().
with open("path/to/my_file.sled", mode="r") as f:
sled_text = f.read()
data = parsled.from_sled(sled_text)
Serialize: Python object to Sled
We have 2 main 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.
data = {}
other_data = {}
# Approach #1
sled_output = parsled.to_sled(data)
# Approach #2
sled_serializer = parsled.SledSerializer()
sled_output = sled_serializer.to_sled(data)
other_sled_output = sled_serializer.to_sled(other_data)
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.1.tar.gz.
File metadata
- Download URL: parsled-0.2.1.tar.gz
- Upload date:
- Size: 23.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 |
a2d25025b80dcf1ff72e2d7811f4a027f262cae17cdba231258a0185a01664eb
|
|
| MD5 |
4995104824fd3edb0f99aeec79a3506d
|
|
| BLAKE2b-256 |
53ddfb761b4b58dc5ca2d708ed0608d0bd8aa2422bfdf70cab78e2982dbfc9fb
|
File details
Details for the file parsled-0.2.1-py3-none-any.whl.
File metadata
- Download URL: parsled-0.2.1-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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 |
64fb9198d0f63146f72e227385a3d83716e3e63c92e8de67a76551efbfe1877d
|
|
| MD5 |
962cd51f4c225bf5461688f30d64c15a
|
|
| BLAKE2b-256 |
bcb50b6c9e3f5bcd1f525e3b871aaba13d32cf42e8e74c5253ca7721abae4113
|