RETIRED, further work has moved to Debian project infrastructure
Go to file
Uiri 19b0f573fe Fix #109: Parse error involving [], {} and '' 2017-06-23 22:53:58 -04:00
examples add travis testing 2016-05-06 15:07:50 -04:00
tests Merge branch 'testing' into master 2017-06-07 22:48:26 -04:00
.flake8 Update Flake8 Preferences 2017-05-26 22:26:32 -04:00
.gitignore add travis testing 2016-05-06 15:07:50 -04:00
.travis.yml Don't run flake8 for py2.6 which is unsupported. 2017-05-26 22:26:32 -04:00
CONTRIBUTING Clean up TESTING.md and rename to CONTRIBUTING 2017-06-07 22:47:21 -04:00
LICENSE 0.9.2 Add notice to LICENSE 2016-07-28 01:24:26 -04:00
MANIFEST.in No reason to escape slashes. MANIFEST.in needs a newline. 2014-06-13 22:31:23 -04:00
README.rst Update README with badges and test info 2017-03-30 02:42:57 -04:00
setup.py PEP8 and Flake8 style compliance 2017-05-26 22:26:32 -04:00
toml.py Fix #109: Parse error involving [], {} and '' 2017-06-23 22:53:58 -04:00
toml.pyi add types 2016-10-03 17:13:08 -04:00

README.rst

TOML

Original repository: https://github.com/uiri/toml

See also https://github.com/mojombo/toml

Python module which parses and emits TOML.

Released under the MIT license.

image

image

Passes https://github.com/uiri/toml-test (fork of https://github.com/BurntSushi/toml-test )

Current Version of the Specification

https://github.com/mojombo/toml/blob/v0.4.0/README.md

QUICK GUIDE

pip install toml

toml.loads --- takes a string to be parsed as toml and returns the corresponding dictionary

toml.dumps --- takes a dictionary and returns a string which is the contents of the corresponding toml file.

There are other functions which I use to dump and load various fragments of toml but dumps and loads will cover most usage.

API Reference

toml.load(f, _dict=dict) - Parses named file or files as toml and returns a dictionary

Args

f: Path to the file to open, array of files to read into single dict or a file descriptor

_dict: (optional) Specifies the class of the returned toml dictionary

Returns

Parsed toml file represented as a dictionary

Raises

TypeError -- When array of non-strings is passed

TypeError -- When f is invalid type

TomlDecodeError: Error while decoding toml

toml.loads(s, _dict=dict): - Parses string as toml

Args

s: String to be parsed

_dict: (optional) Specifies the class of the returned toml dictionary

Returns

Parsed toml file represented as a dictionary

Raises

TypeError: When a non-string is passed

TomlDecodeError: Error while decoding toml

toml.dump(o, f) Writes out dict as toml to a file

Args

o: Object to dump into toml

f: File descriptor where the toml should be stored

Returns

String containing the toml corresponding to dictionary

Raises

TypeError: When anything other than file descriptor is passed

toml.dumps(o) Stringifies input dict as toml

Args

o: Object to dump into toml

Returns

String containing the toml corresponding to dict

Example usage

import toml

with open("conf.toml") as conffile:
    config = toml.loads(conffile.read())
# do stuff with config here
. . .