A better TOML library for python implemented in rust.
Project description
rtoml
A better TOML library for python implemented in rust.
Install
Requires linux and python>=3.7
.
pip install rtoml
Usage
load
def load(toml: Union[str, Path, TextIO]) -> Any: ...
Parse TOML via a string or file and return a python object. The toml
argument may be a str
,
Path
or file object from open()
.
loads
def loads(toml: str) -> Any: ...
Parse a TOML string and return a python object. (provided to match the interface of json
and similar libraries)
dumps
def dumps(obj: Any) -> str: ...
Serialize a python object to TOML.
dump
def dump(obj: Any, file: Union[Path, TextIO]) -> int: ...
Serialize a python object to TOML and write it to a file. file
may be a Path
or file object from open()
.
Example
from datetime import datetime, timezone, timedelta
import rtoml
obj = {
'title': 'TOML Example',
'owner': {
'dob': datetime(1979, 5, 27, 7, 32, tzinfo=timezone(timedelta(hours=-8))),
'name': 'Tom Preston-Werner',
},
'database': {
'connection_max': 5000,
'enabled': True,
'ports': [8001, 8001, 8002],
'server': '192.168.1.1',
},
}
loaded_obj = rtoml.load("""\
# This is a TOML document.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
[database]
server = "192.168.1.1"
ports = [8001, 8001, 8002]
connection_max = 5000
enabled = true
""")
assert loaded_obj == obj
assert rtoml.dumps(obj) == """\
title = "TOML Example"
[owner]
dob = 1979-05-27T07:32:00-08:00
name = "Tom Preston-Werner"
[database]
connection_max = 5000
enabled = true
server = "192.168.1.1"
ports = [8001, 8001, 8002]
"""
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
rtoml-0.2.0.tar.gz
(6.2 kB
view hashes)
Built Distributions
Close
Hashes for rtoml-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76c28f69b2cca925be349fea1fd513e78ca7b7c258cf7d7e7f5dbcda32277dd6 |
|
MD5 | dd656d6e1cc19912655b97df4f1b16f5 |
|
BLAKE2b-256 | 90e1e2b529baa56ee69c48d92b92e5b6517a5b806000cd91e3682653c13af7c7 |
Close
Hashes for rtoml-0.2.0-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a22249cee36cf47de3812ef710fd0a5a32dfbd940bdc8045617ea22a901f0f04 |
|
MD5 | 85d6d9f3bd5d2250f1a9d3731e641dbb |
|
BLAKE2b-256 | 44cfb0c1ff31d0da3e1326ed2fe5e6718b284ba88b9d75d006dedf6f223d9664 |
Close
Hashes for rtoml-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94a6272ae7c380ec0d64b03cd899f43baed284f7b40265b09dc2f128e7a03c3f |
|
MD5 | 052661e475f309159ceb020e7e901d23 |
|
BLAKE2b-256 | cd405b2145952f67f8e3d43fb73b873b3ecc6c5ef5ca14110df9b255268d0eeb |
Close
Hashes for rtoml-0.2.0-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0ae166ddc878df9e58d622396d7cfb63aa142d07d88ca7144576bdf9789379f |
|
MD5 | e001578bc1cc603348d05ac1b302dc1a |
|
BLAKE2b-256 | 4d21adc1dc051a00cb6832ffaf4b8e5259cef108d778c38d0f17ac94f8a2c035 |
Close
Hashes for rtoml-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e123f1fcbc17ad7a611ee6717ad77df8bba01ede6ebaa3163e492484d8f758db |
|
MD5 | 1d06b8732206a5447ebc63dfa86fd2ce |
|
BLAKE2b-256 | c10eb73f1161794f03d4d3d0e932644fce3d18df7059a4023eb0296fedbdb2a0 |
Close
Hashes for rtoml-0.2.0-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee124548e1965d0e862569f80538cbcf7f13eb49ca54a32636218ddeaeac295c |
|
MD5 | 7856aee113431c5a8f958c154adcbb56 |
|
BLAKE2b-256 | f4d976ef50c0af5002f58d62585dd0b10c7836da155fbbe78122d85d863b905d |
Close
Hashes for rtoml-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb77c137e939bdf7aa5b2e16c1ab9a48d34e27890862c19fb1178e8f1a51a9f |
|
MD5 | 2fbcdccbefe6d6cee4d38866cda1498f |
|
BLAKE2b-256 | 85a367c1939f055e157d16cbbfcae794528c35c376dcde584fe41e83f49b6132 |
Close
Hashes for rtoml-0.2.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d14f02d0f2469510f8edcc6cd019f82786e97294b4799f91b54e478b4eafde46 |
|
MD5 | 7d944883dce107847dee59c2563ece37 |
|
BLAKE2b-256 | ed0a6fc0a14593207c62f476430b02c24dae71ef602a16c89f0555b0d34d3d48 |