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
Release history Release notifications | RSS feed
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
File details
Details for the file tomlconfig-1.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: tomlconfig-1.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d27d5985eeb1133bc83c301507dccdb169ab84d2511ec45976d208549d42e27d |
|
MD5 | ae784dcf5087b0c11b31b294ec7e863f |
|
BLAKE2b-256 | d80ba4449d9d86b2df61b390a3b0cb0a96a1cdc0e8e8a900d572c26dce6b1654 |