Skip to main content

A very lite implementation of a toml parser, reader, and writer

Project description

psi_toml

A very lite implementation of a toml parser, reader, and writer

It is not a 1.0.0-compliant TOML library, nor is it intended to be.

It can parse basic toml files to a dict, and write a dict to a toml file using the load and dump methods.

Usage

from psi_toml import toml as toml
    result = toml.load(f_toml)
    toml.dump(data, f_toml)
    toml.parse(strings)

where f_toml is the handle to the toml file, data is a python dict and strings is a list of strings representing key value pairs. E.g.

    nl = '\n'
    strings = [
        'a = 1',
        'b = -1',
        'c = .5',
        'd = abc',
        'e = 3.14',
        'f = "1.414"',
        'g = true',
        'h = "false"',
        (f'i = [{nl}'
            f'"a",{nl}'
            f'"b",{nl}'
            f'"c",{nl}'
            f'"d",{nl}'
            f']'),
        (f'j = {{{nl}'
            f'"a": 1,{nl}'
            f'"b": 2,{nl}'
            f'"c": 3,{nl}'
            f'"d": 4,{nl}'
            f'}}')
    result = toml.parse(strings)

Installation

If you are using Poetry, add psi_toml to your pyproject.toml file by using:

poetry add psi_toml

If not, you can use pip:

pip install psi_toml

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

psi_toml-0.0.17.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

psi_toml-0.0.17-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file psi_toml-0.0.17.tar.gz.

File metadata

  • Download URL: psi_toml-0.0.17.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.6

File hashes

Hashes for psi_toml-0.0.17.tar.gz
Algorithm Hash digest
SHA256 ca128e892c3f01ad12fc616f0d8389d58bfda1bc000c92f435e0385bcd7882b3
MD5 53f9975b4cf7401dc2c693f7ac42ad3d
BLAKE2b-256 6ce21c10d78f1c94e7d112f7e3f9472ee617dba82de1d5ae0c59ee7492e7cce4

See more details on using hashes here.

File details

Details for the file psi_toml-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: psi_toml-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.6

File hashes

Hashes for psi_toml-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 b8be1485e6e85bbc9432600dbd7fc35aed2b698b370fc3469bca2c6a4719b0ec
MD5 df95945ae819bda55ae5bc8a56d9b1d1
BLAKE2b-256 2d9a99e00dd5587a6e09cd57dcf28e6aab3251b51e1527eb74061080bd6063d3

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