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
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 psi_toml-0.0.21.tar.gz.
File metadata
- Download URL: psi_toml-0.0.21.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
496252d01f25ab1a482f13169c6f225e7c543d28dfb45a58cbef6c92b7baac17
|
|
| MD5 |
8662c87180751d57ad24b1b669eb7764
|
|
| BLAKE2b-256 |
a80e99d4d8d63438e2fc7d680950d45f7f9ed42d3bc98f89f9601186e0971ae5
|
File details
Details for the file psi_toml-0.0.21-py3-none-any.whl.
File metadata
- Download URL: psi_toml-0.0.21-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e487526000f975eadf2190286e8d71fea7921c13a50c7617d0df3f1cd38319e
|
|
| MD5 |
b251d157698a39740cd3e9fa856aad7b
|
|
| BLAKE2b-256 |
7f0d9c05bafb98deec74aeb6e6ef07793373d4c53396b13cbab8592f4e53752f
|