All Projects → samuelcolvin → rtoml

samuelcolvin / rtoml

Licence: MIT license
A fast TOML library for python implemented in rust.

Programming Languages

python
139335 projects - #7 most used programming language
rust
11053 projects
Makefile
30231 projects

Projects that are alternatives of or similar to rtoml

Tomlc99
TOML C library
Stars: ✭ 216 (+0.93%)
Mutual labels:  toml
pagser
Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and struct tags for golang crawler
Stars: ✭ 82 (-61.68%)
Mutual labels:  deserialization
gtree
Output tree🌳 or Make directories📁 from #Markdown or Programmatically. Provide CLI, Golang library and Web (using #Wasm ).
Stars: ✭ 88 (-58.88%)
Mutual labels:  toml
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+5.14%)
Mutual labels:  toml
tomlrb
A Racc based TOML parser
Stars: ✭ 63 (-70.56%)
Mutual labels:  toml
dssg
A static site generator with a different approach
Stars: ✭ 15 (-92.99%)
Mutual labels:  toml
Python Benedict
dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘
Stars: ✭ 204 (-4.67%)
Mutual labels:  toml
wildq
Command-line TOML/JSON/INI/YAML/XML/HCL processor using jq c bindings
Stars: ✭ 22 (-89.72%)
Mutual labels:  toml
serdepp
c++ serialize and deserialize adaptor library like rust serde.rs
Stars: ✭ 70 (-67.29%)
Mutual labels:  toml
marshmallow-validators
Use 3rd-party validators (e.g. from WTForms and colander) with marshmallow
Stars: ✭ 24 (-88.79%)
Mutual labels:  deserialization
Joshuto
ranger-like terminal file manager written in Rust
Stars: ✭ 224 (+4.67%)
Mutual labels:  toml
tomlcheck
A syntax checker for TOML files
Stars: ✭ 28 (-86.92%)
Mutual labels:  toml
version-sync
Keep version numbers in sync with Cargo.toml
Stars: ✭ 65 (-69.63%)
Mutual labels:  toml
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+5.14%)
Mutual labels:  toml
har-rs
A HTTP Archive format (HAR) serialization & deserialization library, written in Rust.
Stars: ✭ 25 (-88.32%)
Mutual labels:  deserialization
Awesome Cms
📚 A collection of open and closed source Content Management Systems (CMS) for your perusal.
Stars: ✭ 2,498 (+1067.29%)
Mutual labels:  toml
avro-serde-php
Avro Serialisation/Deserialisation (SerDe) library for PHP 7.3+ & 8.0 with a Symfony Serializer integration
Stars: ✭ 43 (-79.91%)
Mutual labels:  deserialization
toml-f
TOML parser implementation for data serialization and deserialization in Fortran
Stars: ✭ 69 (-67.76%)
Mutual labels:  toml
Anamnesis.jl
Fancy memoizing for expensive functions in Julia.
Stars: ✭ 18 (-91.59%)
Mutual labels:  deserialization
sqlathanor
Serialization / De-serialization support for the SQLAlchemy Declarative ORM
Stars: ✭ 105 (-50.93%)
Mutual labels:  deserialization

rtoml

Actions Status Coverage pypi versions license

A better TOML library for python implemented in rust.

Why Use rtoml

  • Correctness: rtoml is based on the widely used and very stable toml-rs library, it passes all the standard TOML tests as well as having 100% coverage on python code. Other TOML libraries for python I tried all failed to parse some valid TOML.
  • Performance: see github.com/pwwang/toml-bench - rtoml is much faster than pure Python TOML libraries.

Install

Requires python>=3.7, binaries are available from pypi for Linux, macOS and Windows, see here.

pip install rtoml

If no binary is available on pypi for you system configuration; you'll need rust stable installed before you can install rtoml.

Usage

load

def load(toml: Union[str, Path, TextIO]) -> Dict[str, Any]: ...

Parse TOML via a string or file and return a python dictionary. The toml argument may be a str, Path or file object from open().

loads

def loads(toml: str) -> Dict[str, Any]: ...

Parse a TOML string and return a python dictionary. (provided to match the interface of json and similar libraries)

dumps

def dumps(obj: Any, *, pretty: bool = False) -> str: ...

Serialize a python object to TOML.

If pretty is true, output has a more "pretty" format.

dump

def dump(obj: Any, file: Union[Path, TextIO], *, pretty: bool = False) -> int: ...

Serialize a python object to TOML and write it to a file. file may be a Path or file object from open().

If pretty is true, output has a more "pretty" format.

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]
"""
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].