configparser-list
Extends ConfigParser to support lists (getlist)
Install
pip install configparser-list
Tests
To run the tests:
python -m unittest
Examples
Example 1 uses dict
from ConfigParserList import ConfigParser
def list_from_dict():
"""
This example sets the configuration from a dict and then fetchs a list
:return:
"""
str_list = ['A', "B", "C"]
int_list = [1, 2, 3]
d = {'SEC': {
'int': 10,
'float': 1.0,
'liststr': str_list,
'listint': int_list}
}
conf = ConfigParser()
conf.read_dict(d)
alpha = conf.getlist('SEC', 'liststr')
ints = conf.getlistint('SEC', 'listint')
print("list from config (dict): ")
print(f"Alpha {alpha} is of type {type(alpha)}")
print(f"Ints {ints} is of type {type(ints)}")
Example 2 uses str
from ConfigParserList import ConfigParser
def list_from_string():
"""
This example sets the configuration from a string and then fetchs a list
:return:
"""
conf_str = """
[SEC]
int=10,
float=1.0,
liststr=A, B, C
listint=1, 2, 3
"""
conf = ConfigParser()
conf.read_string(conf_str)
alpha = conf.getlist('SEC', 'liststr')
ints = conf.getlistint('SEC', 'listint')
print("list from config (string): ")
print(f"Alpha {alpha} is of type {type(alpha)}")
print(f"Ints {ints} is of type {type(ints)}")
Metadata
Release files for configparser-list 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| configparser-list-1.0.0.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| configparser_list-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / configparser-list-1.0.0.tar.gz
| Download URL | configparser-list-1.0.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bb84a5d4806b7b0fbaf2cad80fa922cc290b8f9135d80fc88ab44c8d249e596
|
|
BLAKE2b-256 checksum How to use checksums |
927b1eabb55ca011f7aecef15b7abd7a69838b22479ed510615057330efdcb79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|
Release files / configparser_list-1.0.0-py3-none-any.whl
| Download URL | configparser_list-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
152b7d8a9bf4f8148cb431c42f8147be147871759b62c97eb116eebe0b9c1159
|
|
BLAKE2b-256 checksum How to use checksums |
6c454e43f6b7a6584ac277db00d1dd1693276b8029813316028efb464fa766f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.7
|