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.8.tar.gz (15.0 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.8-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for psi_toml-0.0.8.tar.gz
Algorithm Hash digest
SHA256 20796384c9c8797b6c2aa87cdda0bf143fe109e58fba799efff7a6157c4e0009
MD5 dd7906c431fe66805f3c1e01c3e60b0c
BLAKE2b-256 a934a36bbf8e2dbbcb6d9477a4343a6542cd23c71042333aff578df0e89768cb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for psi_toml-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1f560c9d4e3c11493e13bb0693f373198ba51116f524c7e55cad312e3e38c5ce
MD5 c3e22d74e72227f8c739ac82e930a4ec
BLAKE2b-256 4b5dc5ab7d0872ae49494cf315f999a7c210d416a9b45ead02c1bf495cfd1252

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