Skip to main content

No project description provided

Project description

English | 简体中文

tomlconfig

Toml configparser made (stupidly) simple for python.

install

pip install tomlconfig

Usage

Define the toml config file "config.toml" as following:

[general]
language = 'en'

[general.editor]
size = 12
font = 'arial'

TomlConfig parse it very simply:

from tomlconfig import TomlConfig

# read config file
config = TomlConfig("config.toml")

# get item
language = config["general.language"] # "en"
size = config["general.editor.size"]  # 12

# in operation
"general.language" in  config  # True"
config.hasSec("general") # True
config.hasSec("general.language") #False

# set item
config["general.editor.font"] = "Roman" # set font=Roman in toml

# add item
config["server.name"] = 'server1' # add a new item
config["newSection"] = {"k1":1} # add a new config section

# delete item
del config["server.name"]

# list item operation
config.insertToChild("general.editor.font", 0, "Arial") # change font from str to list and insert item
config.appendToChild("general.editor.font", "SimSun") # font=["Arial", "Roman", "SimSun"]
# same as config["general.editor.file"].append("SimSun")

# save
config.save()
# saveas
config.save("newfile.toml")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tomlconfig-1.2.1-py2.py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page