Skip to content

felipap/toml-python

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Python parser for TOML

Check out the spec here: https://github.com/mojombo/toml

Feel free to send a pull request.

ToDos and Features

  • Allow multiline arrays.
  • Disallow variable rewriting.
  • Format to JSON.
  • Pypi support (see toml-python)
  • Build unittests.
  • Improve tests (see toml-test)
  • Write de-serializer
  • Improve debugging system.

Installation

pip install toml-python

Usage

TOML from string

>>> import tomlpython
>>> tomlpython.parse("""
	[database]
	server = "192.168.1.1"
	ports = [ 8001, 8001, 8002 ]
""")
{'database': {'ports': [8001, 8001, 8002], 'server': '192.168.1.1'}}

TOML from file

>>> import tomlpython
>>> with open('data.toml') as datafile:
>>>		data = tomlpython.parse(datafile)

TOML to JSON (support to prettify as in json.dumps)

>>> import tomlpython
>>> tomlpython.toJSON("""
		[database]
		server = "192.168.1.1"
		ports = [ 8001, 8001, 8002 ]
    """, indent=4)
{
    "database": {
        "ports": [ 8001, 8001, 8002 ], 
        "server": "192.168.1.1"
    }
}

Testing

License

MIT

About

Python parser for mojombo's TOML.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages