Skip to content

Commit

Permalink
Merge pull request #18 from dnv-opensource/move-config-from-setup-cfg…
Browse files Browse the repository at this point in the history
…-to-pyproject-toml

Move config from setup cfg to pyproject toml
  • Loading branch information
ClaasRostock authored Feb 21, 2024
2 parents baaafdf + a9046ab commit a364e88
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 247 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"terminal.integrated.env.windows": {
"PYTHONPATH": "${workspaceFolder}/src"
},
"python.terminal.activateEnvInCurrentTerminal": true,
"python.languageServer": "Pylance",
"ruff.importStrategy": "fromEnvironment",
Expand Down
23 changes: 20 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e

## [Unreleased]

* -/-


## [0.3.2] - 2024-02-21

### Added
* README.md : Under `Development Setup`, added a step to install current package in "editable" mode, using the pip install -e option.
This removes the need to manually add /src to the PythonPath environment variable in order for debugging and tests to work.

### Removed
* VS Code settings: Removed the setting which added the /src folder to PythonPath. This is no longer necessary. Installing the project itself as a package in "editable" mode, using the pip install -e option, solves the issue and removes the need to manually add /src to the PythonPath environment variable.

### Changed
* Moved all project configuration from setup.cfg to pyproject.toml
* Moved all tox configuration from setup.cfg to tox.ini.
* Moved pytest configuration from pyproject.toml to pytest.ini
* Deleted setup.cfg

### Dependencies
* updated to black[jupyter]==24.1 (from black[jupyter]==23.12)
* updated to version: '==24.1' (from version: '==23.12')
Expand All @@ -13,8 +31,6 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
* updated to sourcery==1.15 (from sourcery==1.14)
* updated to lxml>=5.1 (from lxml>=4.9)

* -/-


## [0.3.1] - 2024-01-09

Expand Down Expand Up @@ -237,7 +253,8 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
* Added support for Python 3.10

<!-- Markdown link & img dfn's -->
[unreleased]: https://github.com/dnv-opensource/dictIO/compare/v0.3.1...HEAD
[unreleased]: https://github.com/dnv-opensource/dictIO/compare/v0.3.2...HEAD
[0.3.2]: https://github.com/dnv-opensource/dictIO/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/dnv-opensource/dictIO/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/dnv-opensource/dictIO/compare/v0.2.9...v0.3.0
[0.2.9]: https://github.com/dnv-opensource/dictIO/compare/v0.2.8...v0.2.9
Expand Down
300 changes: 146 additions & 154 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,154 +1,146 @@
# dictIO
dictIO is a Python package to read, write and manipulate dictionary text files.

It was designed to leverage the versatility of text based dictionary files, or 'dict files' in short, while easing their use in Python through seamless support for Python dicts.

dictIO supports
* reading and writing Python dicts in dict files.
* usage of references and expressions in dict files, dynamically resolved during reading.
* usage of cascaded dict files, allowing separation of a case-agnostic configuration dict and its case-specific parameterization: baseDict + paramDict = caseDict

Further, dictIO
* is widely tolerant in reading different flavours (quotes, preserving comments, etc.)
* can read and write also JSON, XML and OpenFOAM (with some limitations)

## Installation

```sh
pip install dictIO
```

## Usage Example

dictIO provides a simple, high level API that allows reading and writing Python dicts from/to dict files:
```py
from dictIO import DictReader, DictWriter

my_dict = DictReader.read('myDict')
DictWriter.write(my_dict, 'parsed.myDict')
```

The above example reads a dict file, merges any (sub-)dicts included through #include directives, evaluates expressions contained in the dict,
and finally saves the read and evaluated dict with prefix 'parsed' as 'parsed.myDict'.

This sequence of reading, evaluating and writing a dict is also called 'parsing' in dictIO.
Because this task is so common, dictIO provides a convenience class for it:
Using DictParser.parse() the above task can be accomplished in one line of code:
```py
from dictIO import DictParser

DictParser.parse('myDict')
```

The above task can also be invoked from the command line, using the 'dictParser' command line script installed with dictIO:
```sh
dictParser myDict
```

_For more examples and usage, please refer to dictIO's [documentation][dictIO_docs]._


## File Format
The default dictionary file format used by dictIO shares, by intention, some commonalities with the [OpenFOAM](https://www.openfoam.com/documentation/guides/latest/doc/openfoam-guide-input-types.html) file format, but is kept simpler and more tolerant to different flavours of string formatting.

With some limitations, dictIO supports also reading from and writing to [OpenFOAM](https://www.openfoam.com/documentation/guides/latest/doc/openfoam-guide-input-types.html), [Json](https://www.json.org/json-en.html) and [XML](https://www.w3.org/XML/).

_For a detailed documentation of the dict file format used by dictIO, see [File Format](fileFormat.md) in [dictIO's documentation][dictIO_docs] on GitHub Pages._

## Development Setup

1. Install Python 3.9 or higher, i.e. [Python 3.10](https://www.python.org/downloads/release/python-3104/) or [Python 3.11](https://www.python.org/downloads/release/python-3114/)

2. Update pip and setuptools:

```sh
python -m pip install --upgrade pip setuptools
```

3. git clone the dictIO repository into your local development directory:

```sh
git clone https://github.com/dnv-opensource/dictIO path/to/your/dev/dictIO
```

4. In the dictIO root folder:

Create a Python virtual environment:

```sh
python -m venv .venv
```

Activate the virtual environment:

..on Windows:

```sh
> .venv\Scripts\activate.bat
```

..on Linux:

```sh
source .venv/bin/activate
```

Update pip and setuptools:

```sh
(.venv) $ python -m pip install --upgrade pip setuptools
```

Install dictIO's dependencies:
```sh
(.venv) $ pip install -r requirements-dev.txt
```
This should return without errors.
5. Setup your development environment to locate Python source codes:
For example, Visual Studio Code on Windows assumes the Python environment is specified in a `.env` file. <br>
If you are developing and running the Python code from VSCode, make sure to create a `.env` file in the mypackage root folder with below content. <br>
Set the path for `PROJ_DIR` to where your mypackage folder is on your system. <br>
_Note_: `.env` is part of `.gitignore`, such that you do not commit your `.env` file to the repository.
```ini
PROJ_DIR=<path-to-dictIO-root-dir>
PYTHONPATH=${PROJ_DIR}/src
```
6. Test that the installation works (in the mypackage root folder):
```sh
(.venv) $ pytest .
```
## Meta
Copyright (c) 2024 [DNV](https://www.dnv.com) [open source](https://github.com/dnv-opensource)
Frank Lumpitzsch – [@LinkedIn](https://www.linkedin.com/in/frank-lumpitzsch-23013196/) – [email protected]
Claas Rostock – [@LinkedIn](https://www.linkedin.com/in/claasrostock/?locale=en_US) – [email protected]
Seunghyeon Yoo – [@LinkedIn](https://www.linkedin.com/in/seunghyeon-yoo-3625173b/) – [email protected]
Distributed under the MIT license. See [LICENSE](LICENSE.md) for more information.
[https://github.com/dnv-opensource/dictIO](https://github.com/dnv-opensource/dictIO)
## Contributing
1. Fork it (<https://github.com/dnv-opensource/dictIO/fork>)
2. Create your branch (`git checkout -b myBranchName`)
3. Commit your changes (e.g. `git commit -m 'place a descriptive commit message here'`)
4. Push to the branch (e.g. `git push origin myBranchName`)
5. Create a new Pull Request in GitHub
For your contribution, please make sure you follow the [STYLEGUIDE](STYLEGUIDE.md) before creating the Pull Request.
<!-- Markdown link & img dfn's -->
[dictIO_docs]: https://dnv-opensource.github.io/dictIO/README.html
[ospx_docs]: https://dnv-opensource.github.io/ospx/README.html
[farn_docs]: https://dnv-opensource.github.io/farn/README.html
# dictIO
dictIO is a Python package to read, write and manipulate dictionary text files.

It was designed to leverage the versatility of text based dictionary files, or 'dict files' in short, while easing their use in Python through seamless support for Python dicts.

dictIO supports
* reading and writing Python dicts in dict files.
* usage of references and expressions in dict files, dynamically resolved during reading.
* usage of cascaded dict files, allowing separation of a case-agnostic configuration dict and its case-specific parameterization: baseDict + paramDict = caseDict

Further, dictIO
* is widely tolerant in reading different flavours (quotes, preserving comments, etc.)
* can read and write also JSON, XML and OpenFOAM (with some limitations)

## Installation

```sh
pip install dictIO
```

## Usage Example

dictIO provides a simple, high level API that allows reading and writing Python dicts from/to dict files:
```py
from dictIO import DictReader, DictWriter

my_dict = DictReader.read('myDict')
DictWriter.write(my_dict, 'parsed.myDict')
```

The above example reads a dict file, merges any (sub-)dicts included through #include directives, evaluates expressions contained in the dict,
and finally saves the read and evaluated dict with prefix 'parsed' as 'parsed.myDict'.

This sequence of reading, evaluating and writing a dict is also called 'parsing' in dictIO.
Because this task is so common, dictIO provides a convenience class for it:
Using DictParser.parse() the above task can be accomplished in one line of code:
```py
from dictIO import DictParser

DictParser.parse('myDict')
```

The above task can also be invoked from the command line, using the 'dictParser' command line script installed with dictIO:
```sh
dictParser myDict
```

_For more examples and usage, please refer to dictIO's [documentation][dictIO_docs]._


## File Format
The default dictionary file format used by dictIO shares, by intention, some commonalities with the [OpenFOAM](https://www.openfoam.com/documentation/guides/latest/doc/openfoam-guide-input-types.html) file format, but is kept simpler and more tolerant to different flavours of string formatting.

With some limitations, dictIO supports also reading from and writing to [OpenFOAM](https://www.openfoam.com/documentation/guides/latest/doc/openfoam-guide-input-types.html), [Json](https://www.json.org/json-en.html) and [XML](https://www.w3.org/XML/).

_For a detailed documentation of the dict file format used by dictIO, see [File Format](fileFormat.md) in [dictIO's documentation][dictIO_docs] on GitHub Pages._

Check warning on line 57 in README.md

View workflow job for this annotation

GitHub Actions / build_and_publish_documentation / Build and publish documentation

'myst' cross-reference target not found: 'fileFormat.md' [myst.xref_missing]
## Development Setup

1. Install Python 3.9 or higher, i.e. [Python 3.10](https://www.python.org/downloads/release/python-3104/) or [Python 3.11](https://www.python.org/downloads/release/python-3114/)

2. Update pip and setuptools:

```sh
python -m pip install --upgrade pip setuptools
```

3. git clone the dictIO repository into your local development directory:

```sh
git clone https://github.com/dnv-opensource/dictIO path/to/your/dev/dictIO
```

4. In the dictIO root folder:

Create a Python virtual environment:

```sh
python -m venv .venv
```

Activate the virtual environment:

..on Windows:

```sh
> .venv\Scripts\activate.bat
```

..on Linux:

```sh
source .venv/bin/activate
```

Update pip and setuptools:

```sh
(.venv) $ python -m pip install --upgrade pip setuptools
```

Install dictIO's dependencies:
```sh
(.venv) $ pip install -r requirements-dev.txt
```
This should return without errors.
Finally, install dictIO itself, yet not as a regular package but as an _editable_ package instead, using the pip install option -e:
```sh
(.venv) $ pip install -e .
```
5. Test that the installation works (in the dictIO root folder):
```sh
(.venv) $ pytest .
```
## Meta
Copyright (c) 2024 [DNV](https://www.dnv.com) [open source](https://github.com/dnv-opensource)
Frank Lumpitzsch – [@LinkedIn](https://www.linkedin.com/in/frank-lumpitzsch-23013196/) – [email protected]
Claas Rostock – [@LinkedIn](https://www.linkedin.com/in/claasrostock/?locale=en_US) – [email protected]
Seunghyeon Yoo – [@LinkedIn](https://www.linkedin.com/in/seunghyeon-yoo-3625173b/) – [email protected]
Distributed under the MIT license. See [LICENSE](LICENSE.md) for more information.
[https://github.com/dnv-opensource/dictIO](https://github.com/dnv-opensource/dictIO)
## Contributing
1. Fork it (<https://github.com/dnv-opensource/dictIO/fork>)
2. Create your branch (`git checkout -b myBranchName`)
3. Commit your changes (e.g. `git commit -m 'place a descriptive commit message here'`)
4. Push to the branch (e.g. `git push origin myBranchName`)
5. Create a new Pull Request in GitHub
For your contribution, please make sure you follow the [STYLEGUIDE](STYLEGUIDE.md) before creating the Pull Request.
<!-- Markdown link & img dfn's -->
[dictIO_docs]: https://dnv-opensource.github.io/dictIO/README.html
[ospx_docs]: https://dnv-opensource.github.io/ospx/README.html
[farn_docs]: https://dnv-opensource.github.io/farn/README.html
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = "Frank Lumpitzsch, Claas Rostock, Seung Hyeon Yoo"

# The full version, including alpha/beta/rc tags
release = "0.3.1"
release = "0.3.2"

# -- General configuration ---------------------------------------------------

Expand Down
Loading

0 comments on commit a364e88

Please sign in to comment.