Augmented python configparser
Project description
jconfigparser
`jconfigparser` is an extension of the `python` `configparser` standard module which adds the following features inspired by [`TOML`](https://github.com/toml-lang/toml):- Section name depth with dot notation:
[a.b]
- Values on right hand side can be everything that is understood by JSON.
- Values that appear twice or more often are stored as a
list
, see exampleoutput
below (this behavior is configurable).
Example
Say we have the following configuration file in test.jconf
:
[atoms]
file: geometry.in
format: aims
[calculator.aims]
xc: pbesol
charge_mix_param: 0.3
sc_accuracy_rho: 1e-6
output: band 0 0 0 0.00 0.25 0.25 50 Gamma Delta
output: band 0.00 0.25 0.25 0 0.5 0.5 50 Delta X
[calculator.socketio]
port: null
[basissets.aims]
default: light
This file can be parsed with
import jconfigparser as jc
config = jc.Config('test.jconf')
config
will be a modified dict
that hold the information like
{
"atoms": {"file": "geometry.in", "format": "aims"},
"calculator": {
"aims": {
"xc": "pbesol",
"charge_mix_param": 0.3,
"sc_accuracy_rho": 1e-06,
"output": [
"band 0 0 0 0.00 0.25 0.25 50 Gamma Delta",
"band 0.00 0.25 0.25 0 0.5 0.5 50 Delta X",
],
},
"socketio": {"port": None},
},
"basissets": {"aims": {"default": "light"}},
}
Furthermore, config
supports
- Attribute access, e.g.,
config.atoms.file
- Write itself:
config.write("new.jconf")
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
jconfigparser-0.1.1a1.tar.gz
(5.4 kB
view details)
Built Distribution
File details
Details for the file jconfigparser-0.1.1a1.tar.gz
.
File metadata
- Download URL: jconfigparser-0.1.1a1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-88-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf5d340d11f74939b2e91f43a4cb96432a93689719fa59c446b6f3930b540c57 |
|
MD5 | 4aa30e968774c055347a8d5442ef49ba |
|
BLAKE2b-256 | d1803698e3b7d15286cb0d4ae2c3f20583f3d9b591e299c11784678b229fdc6c |
File details
Details for the file jconfigparser-0.1.1a1-py3-none-any.whl
.
File metadata
- Download URL: jconfigparser-0.1.1a1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-88-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d27ff0da39c1908cc5c8fcdc0ac5ab24b9f7540a9a294c583bdaf408f0ad9989 |
|
MD5 | 149abad2e0c59048df05d62f0d5cb1b1 |
|
BLAKE2b-256 | 94cf25e4310a9497d803f4c4ceb4153ba3170c02aa90083242c7914f281909b1 |