Observed since 20 Oct, 17:57 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
access-config-utils
Utilities to work with configurations for the ACCESS climate models.
A Python package providing various utilities to work with configurations for the models developed at ACCESS-NRI.
Parsers:
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 like a Python dict. Everything not touched — comments, blank lines, spacing — is reproduced exactly:
config["data_nml"]["parameterA"] = 2
print(config)
&data_nml
parameterA = 2
parameterB = 'abc'
/
New keys can be added too, and are written in the style of their neighbours. Each value is written
in whichever notation the format uses, so a bool becomes a Fortran logical here:
config["data_nml"]["parameterC"] = True
config["data_nml"]["parameterD"] = [1, 2, 3]
config["new_nml"] = {"parameterE": "def"}
print(config)
&data_nml
parameterA = 2
parameterB = 'abc'
parameterC = .true.
parameterD = 1, 2, 3
/
&new_nml
parameterE = "def"
/
A value the format cannot express raises UnsupportedEntryError rather than writing a file that
no longer means what the dict says — for instance None in a format with no valueless assignment,
or a string containing a space in one with no quoted-string syntax.
Two caveats on the dict and list behaviour. Operations that would add, remove or reorder the
elements of a list value (append, extend, insert, pop, sort, …) raise
NotImplementedError, because each element is tied to the place it came from in the file; assign
a whole new list instead. And replacing an existing block wholesale raises SyntaxError — a block
can be created and edited, but not swapped out.
If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
# Create a virtual environment
python3 -m venv .venv
# Activate the virtual environment
source .venv/bin/activate
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.
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.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
larkEnvironment{
"extras": "",
"marker": null,
"requires_python": "",
"evaluation": "NOT_EVALUATED"
} | lark | runtime |
ruamel.yamlEnvironment{
"extras": "",
"marker": null,
"requires_python": "",
"evaluation": "NOT_EVALUATED"
} | ruamel.yaml | runtime |
pre-commitEnvironment{
"extras": "",
"marker": "extra == \"devel\"",
"requires_python": "",
"evaluation": "NOT_EVALUATED"
} | pre-commit; extra == "devel" | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"test\"",
"requires_python": "",
"evaluation": "NOT_EVALUATED"
} | pytest; extra == "test" | runtime |
pytest-covEnvironment{
"extras": "",
"marker": "extra == \"test\"",
"requires_python": "",
"evaluation": "NOT_EVALUATED"
} | pytest-cov; extra == "test" | runtime |
bdist_wheel · 126.58 KB · Python py3
sdist · 224.61 KB · Python source
Observed since 20 Oct, 17:57 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:1d8672c19ce8043efb1d7495bdd67dc6c4a13df23d95016ca5fe2b79a85ffa89