I/O facility for Idefix/Pluto ini files
Project description
inifix
inifix
in a small Python library with I/O methods to read and write Idefix (or Pluto) inifiles as Python dictionaries.
Installation
$ pip install inifix
Usage
The API is similar to that of toml
and stdlib json
, though intentionally
simplified, and consists in two main user-facing functions: inifix.load
and
inifix.dump
.
import inifix
# read
conf = inifix.load("pluto.ini")
# patch
conf["Time"].update({"CFL": 0.1})
# write back
inifix.dump(conf, "pluto-mod.ini")
inifix.load
supports loading a from an open file
with open("pluto.ini") as fh:
conf = inifix.load(fh)
or from a str/os.Pathlike object representing a file.
Schema Validation
inifix.validate_inifile_schema
can be used to validate an aribitrary
dictionnary as writable to an inifile, following Pluto/Idefix's format. This
will raise an exception (ValueError
) if the dictionnary data
is invalid.
inifix.validate_inifile_schema(data)
Contribution guidelines
We use the pre-commit framework to automatically lint for code style and common pitfals.
Before you commit to your local copy of the repo, please run this from the top level
$ python3 -m pip install -u -e .[dev]
$ pre-commit install
Testing
We use the pytest framework to test inifix
.
The test suite can be run from the top level with a simple pytest
invocation.
$ pytest
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.