Skip to main content

Augmented python configparser

Project description

jconfigparser

python pypi license code style

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 example output 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


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.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

jconfigparser-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file jconfigparser-0.1.2.tar.gz.

File metadata

  • Download URL: jconfigparser-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-99-generic

File hashes

Hashes for jconfigparser-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d308b36fa7aff6ec1cff8767c446fae2f2297627ed85d530311246699175489d
MD5 905a68dc6c29436497771916e530a7af
BLAKE2b-256 a92fc53c7d85443c119531c34a46baec2525a740baa42f123be469faed724d69

See more details on using hashes here.

File details

Details for the file jconfigparser-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jconfigparser-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.8.1 Linux/4.15.0-99-generic

File hashes

Hashes for jconfigparser-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8762c1f02892eaba8079afe6087b6084eafde97a94876f64f92a90620ece27c8
MD5 8509f40039fbbbe483c790cfb15c5bec
BLAKE2b-256 450304ea0b56eb736242941d92adf98d4e2e76a1400d8b0c07618bf19238fa63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page