Skip to main content

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.

  1. Call to_sled().
  2. Instantiate a SledSerializer and call its to_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parsled-0.2.1.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parsled-0.2.1-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

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

Hashes for parsled-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a2d25025b80dcf1ff72e2d7811f4a027f262cae17cdba231258a0185a01664eb
MD5 4995104824fd3edb0f99aeec79a3506d
BLAKE2b-256 53ddfb761b4b58dc5ca2d708ed0608d0bd8aa2422bfdf70cab78e2982dbfc9fb

See more details on using hashes here.

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

Hashes for parsled-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64fb9198d0f63146f72e227385a3d83716e3e63c92e8de67a76551efbfe1877d
MD5 962cd51f4c225bf5461688f30d64c15a
BLAKE2b-256 bcb50b6c9e3f5bcd1f525e3b871aaba13d32cf42e8e74c5253ca7721abae4113

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page