Augmented python configparser
Project description
jconfigparser
jconfigparser
is an extension of the python
configparser
standard module which adds the following features inspired by 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.1.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file jconfigparser-0.1.1.tar.gz
.
File metadata
- Download URL: jconfigparser-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-91-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ec555aadfd169f3e0a866a6a8e62e62c9dd24e2464ed13dc6d78c046b61cc0e |
|
MD5 | f316ed87f99310623950925b6bf218b2 |
|
BLAKE2b-256 | 014a0dfdf51e48891331a09cac72d527bc07ae86d757d067dbe9cd0e56a3935c |
File details
Details for the file jconfigparser-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: jconfigparser-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-91-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068f510b18e93a10811bdd3858bcf43c518f3c7d7723ded8672e0f3745c83f93 |
|
MD5 | 6292aace452553ea5a1f7e2590083246 |
|
BLAKE2b-256 | 62cab4f9700d7ae320a4e81f83638d9318a25623cc9c80bb794853a900473845 |