Dead simple configuration file parser.
Project description
what?
simpleconfig is a Python module that reads INI files into a dictionary. It is both Python 2 and Python 3 compatible.
why?
I’ve written this code several times for a couple projects; I got sick of copying the file over to new project directories.
how?
Both a parse and parse_string function are provided. The former parses config files, and the latter parses a config file serialised into a string.
return value and example
Both parse() and parse_string return a dictionary (see below) where each section is a key at the top level, and is a dictionary of key=value pairs itself. For example, given the config file:
>>> config = """ # random version information version = 1.0.5 ; last modified 1 April 2001 by John Doe ; example taken from wikipedia [owner] name=John Doe organization=Acme Widgets Inc. [database] # use IP address in case network name resolution is not working server=192.0.2.62 port=143 file="payroll.dat" """
Parsing this with simpleconfig yields:
>>> import simpleconfig as sc >>> cfg = sc.parse_string(config) >>> cfg['owner']['name'] 'John Doe' >>> cfg.owner.name 'John Doe'
Note that the dictionary type returned by the parse functions is actually a kutils.dicts.AttrDictDict, which is derived from the dict type and can be used wherever a dict can.
license
simpleconfig is released under an ISC license.
additional
The module is only tested for compatibility against Python 2.7 and Python 3.3+. There are no guarantees (or attempts) at compatibility with previous version of Python.
The docs are on RTD.
The source for simpleconfig is online:
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
Built Distributions
File details
Details for the file simpleconfig-2.0.tar.gz
.
File metadata
- Download URL: simpleconfig-2.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c237d528a71218a20d9c3f85d4b37e03d628ee9effe501e180a378f903c649e8 |
|
MD5 | 5e9e776bd6844d51055455b58443b8b2 |
|
BLAKE2b-256 | 1649e7df279b3cae25790f32d495e519a568102cada5a4f0c409219b683e0ee7 |
File details
Details for the file simpleconfig-2.0-py3-none-any.whl
.
File metadata
- Download URL: simpleconfig-2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39ef3997931572c8365fb65fdc31686f1f91554d5ffb1025563a1df695b66f81 |
|
MD5 | d1b50bc62d3df9bd82506ffefed3e1a5 |
|
BLAKE2b-256 | 6fe21ff596a21a89ffa73c66f01db8a82a200944bbeec4ea4ae1970d0ddddaa7 |
File details
Details for the file simpleconfig-2.0-py2-none-any.whl
.
File metadata
- Download URL: simpleconfig-2.0-py2-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29301670b95e3b47d78d123c4f0d89cd0f44b5d46e5ff8d95ba051c9d5d6d404 |
|
MD5 | e1e1f0860e579b875cf89d7cf50e2653 |
|
BLAKE2b-256 | 56a0b9d7200088a421f25007ef15811b4bb26f2339e3d6a6d0e6ff4587a12059 |