ExtendParser extend stanrad ConfigParser for some functionality.
Project description
Extend parser is set of ConfigParser extensions. All extensions are added to one final class ExtendParser. For more details see source code, or use help.
- copyright:
2018, see AUTHORS for more details
- license:
BSD, see LICENSE for more details
Library
ExtendParser
>>> from extendparser import ExtendParser
>>> cp = ExtendParser()
Include
Include class can append content of other configuration to calling. Let’s have these configuration files:
# test.ini
[main]
string = value
.include numbers.ini
# numbers.ini
integer = 42
.include const.ini
# const.ini
pi = 3.14
Here is the string buffer which ConfiguratinParser will read:
# test.ini
[main]
string = value
# numbers.ini
integer = 42
# const.ini
pi = 3.14
Get
Get class have two smart methods get_option and get_section to get value(s) in any type you want.
>>> from extendparser.get import Get
>>> cp = Get()
>>> print(cp.get_option("test", "number", target=int, fallback=1))
1
>>> print(cp.get_option("test", "list", target=list, fallback=["a"],
... delimiter=','))
['a']
>>> cp.add_section("test")
>>> cp.set("test", "tuple", "a:b:c")
>>> print(cp.get_option("test", "tuple", target=tuple, delimiter=':'))
('a', 'b', 'c')
>>> print(cp.get_section("test", (("tuple", tuple, tuple(), ':'),
... ("string", str, "value"))))
{'tuple': ('a', 'b', 'c'), 'string': 'value'}
Installation
~$ pip install extendparser
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 Distribution
extendparser-0.2.0.tar.gz
(6.9 kB
view hashes)
Built Distributions
Close
Hashes for extendparser-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f03a2bc3a2a0bb27694c9e5ecf409831cff4bef3fe5f94446ed56a1510529245 |
|
MD5 | 8c1d9f414b86e1b86cf0e4e920c979b3 |
|
BLAKE2b-256 | b3d847bd785c9dd8daf97cebaa4434d7e01b5dc59977bd4397c5032da39ec070 |
Close
Hashes for extendparser-0.2.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c5b131677425ecc86281622113db40371f66ea8ddf4a3c573606d1755dbc6f9 |
|
MD5 | d197b91c0a505197dfe21ab35d8aff0c |
|
BLAKE2b-256 | 47dd1e231d0c15c2f682fe90dce01147edfcb85d4a0ff7afeca31a4b1bdfed47 |