{"id":26892061,"url":"https://github.com/dnv-opensource/dictio","last_synced_at":"2025-05-12T14:11:32.372Z","repository":{"id":57677544,"uuid":"428229993","full_name":"dnv-opensource/dictIO","owner":"dnv-opensource","description":"Python package to read, write and manipulate dictionary text files. Supports dictIOs native file format, as well as JSON, XML and OpenFOAM.","archived":false,"fork":false,"pushed_at":"2025-05-12T05:37:21.000Z","size":1368,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-12T14:11:22.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dnv-opensource.github.io/dictIO/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnv-opensource.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-11-15T11:07:20.000Z","updated_at":"2025-03-14T16:52:28.000Z","dependencies_parsed_at":"2023-12-11T07:42:49.165Z","dependency_job_id":"e63447f2-c54a-412b-aa56-70b48f993a7e","html_url":"https://github.com/dnv-opensource/dictIO","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2FdictIO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2FdictIO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2FdictIO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2FdictIO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnv-opensource","download_url":"https://codeload.github.com/dnv-opensource/dictIO/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754219,"owners_count":21958842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-31T22:48:59.917Z","updated_at":"2025-05-12T14:11:32.329Z","avatar_url":"https://github.com/dnv-opensource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![pypi](https://img.shields.io/pypi/v/dictIO.svg?color=blue)](https://pypi.python.org/pypi/dictIO)\r\n[![versions](https://img.shields.io/pypi/pyversions/dictIO.svg?color=blue)](https://pypi.python.org/pypi/dictIO)\r\n[![license](https://img.shields.io/pypi/l/dictIO.svg)](https://github.com/dnv-opensource/dictIO/blob/main/LICENSE)\r\n![ci](https://img.shields.io/github/actions/workflow/status/dnv-opensource/dictIO/.github%2Fworkflows%2Fnightly_build.yml?label=ci)\r\n[![docs](https://img.shields.io/github/actions/workflow/status/dnv-opensource/dictIO/.github%2Fworkflows%2Fpush_to_release.yml?label=docs)][dictIO_docs]\r\n\r\n# dictIO\r\ndictIO is a Python package to read, write and manipulate dictionary text files.\r\n\r\nIt 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.\r\n\r\ndictIO supports\r\n* reading and writing Python dicts in dict files.\r\n* usage of references and expressions in dict files, dynamically resolved during reading.\r\n* usage of cascaded dict files, allowing separation of a case-agnostic configuration dict and its case-specific parameterization: baseDict + paramDict = caseDict\r\n\r\nFurther, dictIO\r\n* is widely tolerant in reading different flavours (quotes, preserving comments, etc.)\r\n* can read and write also JSON, XML and OpenFOAM (with some limitations)\r\n\r\n## Installation\r\n\r\n```sh\r\npip install dictIO\r\n```\r\n\r\n## Usage Example\r\n\r\ndictIO's core class is `SDict`, a generic data structure for serializable dictionaries. \u003cbr\u003e\r\n`SDict` inherits from Python's builtin `dict`. It can hence be used transparently in any context where a `dict` or any other `MutableMapping` type is expected.\r\n\r\nYou can use `SDict` the same way you use `dict`. E.g. you can pass a dict literal to its constructor:\r\n```py\r\nfrom dictIO import SDict\r\n\r\nmy_dict: SDict[str, int] = SDict(\r\n    {\r\n        \"foo\": 1,\r\n        \"bar\": 2,\r\n    }\r\n)\r\n```\r\n\r\nThe simplest way to to dump and load a dict to / from a file, is to use SDict's `dump()` and `load()` instance methods:\r\n\r\nTo dump `my_dict` to a file, use `.dump()`:\r\n```py\r\nmy_dict.dump(\"myDict\")\r\n```\r\n\r\nTo load the formerly dumped file into a new dict, use `.load()`:\r\n```py\r\nmy_dict_loaded: SDict[str, int] = SDict().load(\"myDict\")\r\n```\r\n\r\nIn cases where you need more control over how dict files are read and written, \u003cbr\u003e\r\ndictIO's `DictReader` and `DictWriter` classes offer this flexibility, while still maintaining a simple and high level API:\r\n```py\r\nfrom dictIO import DictReader, DictWriter\r\n\r\nmy_dict = DictReader.read('myDict')\r\nDictWriter.write(my_dict, 'parsed.myDict')\r\n```\r\n\r\nThe above example reads a dict file, merges any (sub-)dicts included through #include directives, evaluates expressions contained in the dict,\r\nand finally saves the read and evaluated dict with prefix 'parsed' as 'parsed.myDict'.\r\n\r\nThis sequence of reading, evaluating and writing a dict is also called 'parsing' in dictIO.\r\nBecause this task is so common, dictIO provides a convenience class for it:\r\nUsing `DictParser.parse()` the above task can be accomplished in one line of code:\r\n```py\r\nfrom dictIO import DictParser\r\n\r\nDictParser.parse('myDict')\r\n```\r\n\r\nThe `parse` operation can also be executed from the command line, using the 'dictParser' command line script installed with dictIO:\r\n```sh\r\ndictParser myDict\r\n```\r\n\r\n_For more examples and usage, please refer to dictIO's [documentation][dictIO_docs]._\r\n\r\n\r\n## File Format\r\nThe native 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.\r\n\r\nWith 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/).\r\n\r\n_For a detailed documentation of the native file format used by dictIO, see [File Format](fileFormat.rst) in [dictIO's documentation][dictIO_docs] on GitHub Pages._\r\n\r\n## Development Setup\r\n\r\n### 1. Install uv\r\nThis project uses `uv` as package manager.\r\nIf you haven't already, install [uv](https://docs.astral.sh/uv), preferably using it's [\"Standalone installer\"](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2) method: \u003cbr\u003e\r\n..on Windows:\r\n```sh\r\npowershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"\r\n```\r\n..on MacOS and Linux:\r\n```sh\r\ncurl -LsSf https://astral.sh/uv/install.sh | sh\r\n```\r\n(see [docs.astral.sh/uv](https://docs.astral.sh/uv/getting-started/installation/) for all / alternative installation methods.)\r\n\r\nOnce installed, you can update `uv` to its latest version, anytime, by running:\r\n```sh\r\nuv self update\r\n```\r\n\r\n### 2. Install Python\r\nThis project requires Python 3.10 or later. \u003cbr\u003e\r\nIf you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through `uv`:\r\n```sh\r\nuv python install\r\n```\r\nThis will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.\r\n\r\nAlternatively, and if you want a standalone version of Python on your machine, you can install Python either via `winget`:\r\n```sh\r\nwinget install --id Python.Python\r\n```\r\nor you can download and install Python from the [python.org](https://www.python.org/downloads/) website.\r\n\r\n### 3. Clone the repository\r\nClone the dictIO repository into your local development directory:\r\n```sh\r\ngit clone https://github.com/dnv-opensource/dictIO path/to/your/dev/dictIO\r\n```\r\nChange into the project directory after cloning:\r\n```sh\r\ncd dictIO\r\n```\r\n\r\n### 4. Install dependencies\r\nRun `uv sync` to create a virtual environment and install all project dependencies into it:\r\n```sh\r\nuv sync\r\n```\r\n\u003e **Note**: Using `--no-dev` will omit installing development dependencies.\r\n\r\n\u003e **Note**: `uv` will create a new virtual environment called `.venv` in the project root directory when running\r\n\u003e `uv sync` the first time. Optionally, you can create your own virtual environment using e.g. `uv venv`, before running\r\n\u003e `uv sync`.\r\n\r\n### 5. (Optional) Activate the virtual environment\r\nWhen using `uv`, there is in almost all cases no longer a need to manually activate the virtual environment. \u003cbr\u003e\r\n`uv` will find the `.venv` virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via `uv` inside your project folder structure:\r\n```sh\r\nuv run \u003ccommand\u003e\r\n```\r\n\r\nHowever, you still _can_ manually activate the virtual environment if needed.\r\nWhen developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings.\r\nTo manually activate the virtual environment, run one of the \"known\" legacy commands: \u003cbr\u003e\r\n..on Windows:\r\n```sh\r\n.venv\\Scripts\\activate.bat\r\n```\r\n..on Linux:\r\n```sh\r\nsource .venv/bin/activate\r\n```\r\n\r\n### 6. Install pre-commit hooks\r\nThe `.pre-commit-config.yaml` file in the project root directory contains a configuration for pre-commit hooks.\r\nTo install the pre-commit hooks defined therein in your local git repository, run:\r\n```sh\r\nuv run pre-commit install\r\n```\r\n\r\nAll pre-commit hooks configured in `.pre-commit-config.yaml` will now run each time you commit changes.\r\n\r\npre-commit can also manually be invoked, at anytime, using:\r\n```sh\r\nuv run pre-commit run --all-files\r\n```\r\n\r\nTo skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:\r\n```sh\r\nuv run git commit -m \u003cMSG\u003e --no-verify\r\n```\r\n\r\nTo update the hooks configured in `.pre-commit-config.yaml` to their newest versions, run:\r\n```sh\r\nuv run pre-commit autoupdate\r\n```\r\n\r\n### 7. Test that the installation works\r\nTo test that the installation works, run pytest in the project root folder:\r\n```sh\r\nuv run pytest\r\n```\r\n\r\n## Meta\r\n\r\nCopyright (c) 2024 [DNV](https://www.dnv.com) AS. All rights reserved.\r\n\r\nFrank Lumpitzsch - [@LinkedIn](https://www.linkedin.com/in/frank-lumpitzsch-23013196/) - frank.lumpitzsch@dnv.com\r\n\r\nClaas Rostock - [@LinkedIn](https://www.linkedin.com/in/claasrostock/?locale=en_US) - claas.rostock@dnv.com\r\n\r\nSeunghyeon Yoo - [@LinkedIn](https://www.linkedin.com/in/seunghyeon-yoo-3625173b/) - seunghyeon.yoo@dnv.com\r\n\r\nDistributed under the MIT license. See [LICENSE](LICENSE.md) for more information.\r\n\r\n[https://github.com/dnv-opensource/dictIO](https://github.com/dnv-opensource/dictIO)\r\n\r\n## Contributing\r\n\r\n1. Fork it (\u003chttps://github.com/dnv-opensource/dictIO/fork\u003e)\r\n2. Create an issue in your GitHub repo\r\n3. Create your branch based on the issue number and type (`git checkout -b issue-name`)\r\n4. Evaluate and stage the changes you want to commit (`git add -i`)\r\n5. Commit your changes (`git commit -am 'place a descriptive commit message here'`)\r\n6. Push to the branch (`git push origin issue-name`)\r\n7. Create a new Pull Request in GitHub\r\n\r\nFor your contribution, please make sure you follow the [STYLEGUIDE](STYLEGUIDE.md) before creating the Pull Request.\r\n\r\n\u003c!-- Markdown link \u0026 img dfn's --\u003e\r\n[dictIO_docs]: https://dnv-opensource.github.io/dictIO/README.html\r\n[ospx_docs]: https://dnv-opensource.github.io/ospx/README.html\r\n[farn_docs]: https://dnv-opensource.github.io/farn/README.html\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fdictio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnv-opensource%2Fdictio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fdictio/lists"}