Welcome to utf8config Documentation
utf8 format config file IO tool.
Features:
Comment Control. (You can choose ignore comment or not while dumping)
Allow unicode character.
Smart parser for number, string, boolean, None, list.
Example:
# content of config.ini ### DEFAULT is the default section ### DEFAULT是默认Section [DEFAULT] localhost = 192.168.0.1 # IP地址, 默认 192.168.0.1 port = 8080 # 端口号 ### 下面的是尝试连接的最长时间 connection_timeout = 60 # 单位是秒, 默认60 # Test是用来测试各种数据类型是否能被成功解析的 # 用Configuration.load()看看会不会成功吧 [TEST] # Single Value # 以下是单值项 # 即非列表的值 int = 123 # 123 int_pos = +123 # 123 int_neg = -123 # -123 float = 3.14 # 3.14 float_pos = +3.14 # 3.14 float_neg = -3.14 # -3.14 str = Hello World! # str "Hello World!" str_quote = 'Good Boy' # str "Good Boy" str_double_quote = "Bad Boy" # str "Bad Boy" str_quote_in_quote = '"Boy"' # str '"Boy"' str_int = '123' # str "123" str_float = '3.14' # str "3.14" str_bool = 'True' # str "True" str_path = C:\用户\管理员 # str "C:\用户\管理员" str_utf8 = 中文 # str "中文" bool_true = True # True bool_yes = Yes # True bool_false = False # False bool_no = No # No none_none = None # None none_null = null # None none = # None # List Value # 以下是各种列表 empty_list = , # Empty list [] int_list = 1, -2, 3 # [1, -2, 3] int_none_list = , -2,3 # [None -2, 3] float_list = 1.1, -2.2, 3.3 # [1.1, -2.2, 3.3] float_none_list = , -2.2,3.3 # [None -2.2, 3.3] str_list = a, b, c # ["a", "b", "c"] str_single_quote_list = '1', '2', '3' # ["1", "2", "3"] str_double_quote_list = "1", "2", "3" # ["1", "2", "3"] str_path_list = C:\windows, C:\中文 # ["C:\windows", "C:\中文"] str_special_list = a, '1', '3.14', "True", "no", ,"None" # ["a", "1", "3.14", "True", "no", "None"] bool_list = True, False # [True, False] bool_yes_no_list = Yes, No # [True, False]
Usage:
Read and Write:
from utf8config import Config, Section, Field
config = Config.load("config.ini")
for section_name, section in config.items():
...
section = Config["DEFAULT"]
for field_name, field in section.items():
...
localhost = section["localhost"]
port = section["port"]
localhost.key # "localhost"
localhost.value # "192.168.0.1"
with open("config.ini", "w") as f:
text = config.dump("config.ini", ignore_comment=True)
f.write(text)
Programmatically Construct Config:
config = Config()
DEFAULT = config["DEFAULT"]
DEFAULT.add_field(Field(key="localhost", value="192.168.0.1"))
TEST = Section("TEST")
TEST.add_field(Field(key="numbers", value=[1, 2, 3]))
config.add_section(TEST)
Quick Links
Install
utf8config is released on PyPI, so all you need is:
$ pip install utf8config
To upgrade to latest version:
$ pip install --upgrade utf8config
Metadata
Release files for utf8config 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| utf8config-0.0.2.tar.gz | 23.9 kB | Without provenance | Details for utf8config-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| utf8config-0.0.2-py2-none-any.whl | Python 2 | none | any | Details for utf8config-0.0.2-py2-none-any.whl |
Total release size: 59.0 kB
Release files / utf8config-0.0.2.tar.gz
| Download URL | utf8config-0.0.2.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa2d7bc2710c49916b6c250695b77835826ebd29761b26ce3945fffe394be427
|
|
BLAKE2b-256 checksum How to use checksums |
1e99e724bb6ffb9df8c512c7c40f05393dbacb00294ab434bcfa8c6c85ab19d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / utf8config-0.0.2-py2-none-any.whl
| Download URL | utf8config-0.0.2-py2-none-any.whl |
|---|---|
| Size | 35.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
c0b57c6a888ae18223ddc9489bb8681a9b4842745295ffb48a3167b5c53f2780
|
|
BLAKE2b-256 checksum How to use checksums |
debe8d95b0f1e669b90fb0e15c5e9203cb66f858cb719e4a4df7711edae15520
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for utf8config 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.