All Projects → alethiophile → qtoml

alethiophile / qtoml

Licence: MIT License
Another Python TOML encoder/decoder

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to qtoml

rcpptoml
Rcpp Bindings to C++ parser for TOML files
Stars: ✭ 26 (+0%)
Mutual labels:  toml-parser, toml, toml-parsing
pp-toml
Paul's Parser for Tom's Own Minimal Language
Stars: ✭ 17 (-34.62%)
Mutual labels:  toml-parser, toml
Tomlet
Zero-Dependency, model-based TOML De/Serializer for .NET
Stars: ✭ 56 (+115.38%)
Mutual labels:  toml-parser, toml
tomli
A lil' TOML parser
Stars: ✭ 313 (+1103.85%)
Mutual labels:  toml-parser, toml
pytomlpp
A python wrapper for tomlplusplus
Stars: ✭ 56 (+115.38%)
Mutual labels:  toml-parser, toml
toml-f
TOML parser implementation for data serialization and deserialization in Fortran
Stars: ✭ 69 (+165.38%)
Mutual labels:  toml-parser, toml
tomlcpp
No fanfare TOML C++ Library
Stars: ✭ 21 (-19.23%)
Mutual labels:  toml-parser, toml
tomland
🏝 Bidirectional TOML serialization
Stars: ✭ 103 (+296.15%)
Mutual labels:  toml-parser, toml
transfer
Converts from one encoding to another. Supported formats HCL ⇄ JSON ⇄ YAML⇄TOML⇄XML⇄plist⇄pickle⇄properties ...
Stars: ✭ 70 (+169.23%)
Mutual labels:  toml
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+230.77%)
Mutual labels:  toml
contentful-export
Extract Contentful to Hugo
Stars: ✭ 22 (-15.38%)
Mutual labels:  toml
cfg-rs
A Configuration Library for Rust Applications
Stars: ✭ 18 (-30.77%)
Mutual labels:  toml
Molten
[WIP] Molten - Style-preserving TOML parser.
Stars: ✭ 36 (+38.46%)
Mutual labels:  toml
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-23.08%)
Mutual labels:  toml
TOMLDecoder
From TOML to Swift Codable types.
Stars: ✭ 52 (+100%)
Mutual labels:  toml
htoml
TOML file format parser in Haskell
Stars: ✭ 39 (+50%)
Mutual labels:  toml
goconf
Configuration loader in Go
Stars: ✭ 23 (-11.54%)
Mutual labels:  toml
configo
Configo is a go library to parse toml configuration using struct tags
Stars: ✭ 33 (+26.92%)
Mutual labels:  toml
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+176.92%)
Mutual labels:  toml
tree-sitter-toml
TOML grammar for tree-sitter
Stars: ✭ 23 (-11.54%)
Mutual labels:  toml

qTOML

qtoml is another Python TOML encoder/decoder. I wrote it because I found uiri/toml too unstable, and PyTOML too slow.

For information concerning the TOML language, see toml-lang/toml.

qtoml currently supports TOML v0.5.0.

Usage

qtoml is available on PyPI. You can install it using pip:

$ pip install qtoml

qtoml supports the standard load/loads/dump/dumps API common to most similar modules. Usage:

>>> import qtoml
>>> toml_string = """
... test_value = 7
... """
>>> qtoml.loads(toml_string)
{'test_value': 7}
>>> print(qtoml.dumps({'a': 4, 'b': 5.0}))
a = 4
b = 5.0

>>> infile = open('filename.toml', 'r')
>>> parsed_structure = qtoml.load(infile)
>>> outfile = open('new_filename.toml', 'w')
>>> qtoml.dump(parsed_structure, outfile)

TOML supports a fairly complete subset of the Python data model, but notably does not include a null or None value. If you have a large dictionary from somewhere else including None values, it can occasionally be useful to substitute them on encode:

>>> print(qtoml.dumps({ 'none': None }))
qtoml.encoder.TOMLEncodeError: TOML cannot encode None
>>> print(qtoml.dumps({ 'none': None }, encode_none='None'))
none = 'None'

The encode_none value must be a replacement encodable by TOML, such as zero or a string.

This breaks reversibility of the encoding, by rendering None values indistinguishable from literal occurrences of whatever sentinel you chose. Thus, it should not be used when exact representations are critical.

Development/testing

qtoml uses the poetry tool for project management. To check out the project for development, run:

$ git clone --recurse-submodules https://github.com/alethiophile/qtoml
$ cd qtoml
$ poetry install

This assumes poetry is already installed. The package and dependencies will be installed in the currently active virtualenv if there is one, or a project-specific new one created if not.

qtoml is tested against the alethiophile/toml-test test suite, forked from uiri's fork of the original by BurntSushi. To run the tests, after checking out the project as shown above, enter the tests directory and run:

$ pytest              # if you already had a virtualenv active
$ poetry run pytest   # if you didn't

License

This project is available under the terms of the MIT license.

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].