A Python package providing various utilities to work with configurations for the models developed at ACCESS-NRI.
Parsers:
- Various parsers for configuration files used across ACCESS-NRI models
- Support for round-trip parsing, preserving comments and formatting
- Simple API
Coming soon.
You can install the latest release directly from PyPI:
pip install access-config-utils
If you prefer to install from source:
git clone https://github.com/ACCESS-NRI/access-config-utils.git
cd access-config-utils
pip install .
Here is a simple example of how to parse a text and modify its contents.
To parse some text, one just needs to call the parse
function of the appropriate parser:
from access.config import FortranNMLParser
text = '''&data_nml
parameterA = 1
parameterB = 'abc'
/'''
config = FortranNMLParser().parse(text)
print(config)
&data_nml
parameterA = 1
parameterB = 'abc'
/
The parsed content can then be modified just like any Python dict:
config["data_nml"]["parameterA"] = 2
print(config)
&data_nml
parameterA = 2
parameterB = 'abc'
/
If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
- Create and activate a virtual environment
# Create a virtual environment
python3 -m venv .venv
# Activate the virtual environment
source .venv/bin/activate
- Install in editable mode with development and test dependencies
pip install -e ".[devel,test]"
This will install the package in editable mode, meaning changes to the source code are reflected immediately without reinstallation. Development dependencies such as testing tools will also be installed.
- Run the test suite
pytest
Contributions are welcome! Please open an issue or submit a pull request if you’d like to add features, fix bugs, or improve documentation.
For significant contributions, we recommend discussing proposed changes in an issue before opening a pull request.
This project is licensed under the Apache 2.0 License.