|
1 | 1 | # access-parsers
|
2 | 2 |
|
3 |
| -*A Python package of various functions to read and write configuration files for the models developed at [ACCESS](https://github.com/ACCESS-NRI).* |
4 |
| - |
5 | 3 |  [](https://codecov.io/github/ACCESS-NRI/access-parsers) [](https://opensource.org/license/apache-2-0) [](https://github.com/psf/black)
|
| 4 | + |
| 5 | +## About |
| 6 | + |
| 7 | +A Python package providing various parsers to read and write various types of files used in the models developed at [ACCESS-NRI](https://github.com/ACCESS-NRI). |
| 8 | + |
| 9 | +## Key Features |
| 10 | + |
| 11 | +- Parsers for configuration files used across ACCESS-NRI models |
| 12 | +- Support for round-trip parsing, preserving comments and formatting |
| 13 | +- Simple API |
| 14 | + |
| 15 | +## Documentation |
| 16 | + |
| 17 | +Coming soon. |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +### Using pip |
| 22 | + |
| 23 | +You can install the latest release directly from PyPI: |
| 24 | +'''shell |
| 25 | +pip install access-parsers |
| 26 | +''' |
| 27 | + |
| 28 | +### From source |
| 29 | + |
| 30 | +If you prefer to install from source: |
| 31 | +'''shell |
| 32 | +git clone https://github.com/ACCESS-NRI/access-parsers.git |
| 33 | +cd access-parsers |
| 34 | +pip install . |
| 35 | +''' |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +Here is a simple example of how to parse a text and modify its contents. |
| 40 | + |
| 41 | +To parse some text, one just needs to call the `parse` function of the appropriate parser: |
| 42 | +'''python |
| 43 | +from access.parsers import FortranNMLParser |
| 44 | + |
| 45 | +text = '''&data_nml |
| 46 | + parameterA = 1 |
| 47 | + parameterB = 'abc' |
| 48 | +/''' |
| 49 | + |
| 50 | +config = FortranNMLParser().parse(text) |
| 51 | +print(config) |
| 52 | +''' |
| 53 | +'''python |
| 54 | +&data_nml |
| 55 | +parameterA = 1 |
| 56 | +parameterB = 'abc' |
| 57 | +/ |
| 58 | +''' |
| 59 | + |
| 60 | +The parsed content can then be modified just like any Python dict: |
| 61 | +'''python |
| 62 | +config["data_nml"]["parameterA"] = 2 |
| 63 | +print(config) |
| 64 | +''' |
| 65 | +'''python |
| 66 | +&data_nml |
| 67 | +parameterA = 2 |
| 68 | +parameterB = 'abc' |
| 69 | +/ |
| 70 | +''' |
| 71 | + |
| 72 | +## Development installation |
| 73 | + |
| 74 | +If you intend to contribute or modify the package, it is recommended to work inside a virtual environment. |
| 75 | + |
| 76 | +1. Create and activate a virtual environment |
| 77 | +'''shell |
| 78 | +# Create a virtual environment |
| 79 | +python3 -m venv .venv |
| 80 | + |
| 81 | +# Activate the virtual environment |
| 82 | +source .venv/bin/activate |
| 83 | +''' |
| 84 | + |
| 85 | +2. Install in editable mode with development and test dependencies |
| 86 | +'''shell |
| 87 | +pip install -e ".[devel,test]" |
| 88 | +''' |
| 89 | +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. |
| 90 | + |
| 91 | +3. Run the test suite |
| 92 | +'''shell |
| 93 | +pytest |
| 94 | +''' |
| 95 | + |
| 96 | +## Contributing |
| 97 | + |
| 98 | +Contributions are welcome! Please open an issue or submit a pull request if you’d like to add features, fix bugs, or improve documentation. |
| 99 | + |
| 100 | +For significant contributions, we recommend discussing proposed changes in an issue before opening a pull request. |
| 101 | + |
| 102 | +## License |
| 103 | + |
| 104 | +This project is licensed under the Apache 2.0 License. |
0 commit comments