[![PyPI version](https://badge.fury.io/py/toml_union.svg)](https://pypi.org/project/toml_union/)
[![Downloads](https://pepy.tech/badge/toml_union)](https://pepy.tech/project/toml_union)
[![Downloads](https://pepy.tech/badge/toml_union/month)](https://pepy.tech/project/toml_union)
[![Downloads](https://pepy.tech/badge/toml_union/week)](https://pepy.tech/project/toml_union)
- [About](#about)
- [Python usage example](#python-usage-example)
- [Overrides](#overrides)
- [CLI](#cli)
# About
```sh
pip install toml-union
```
This PyPI package is indeed located in one script and combines several `*.toml` files (usially `pyproject.toml`) into one. If it finds some conflicts between items, they will be kept for manual review.
It has a docker image (`docker pull pasaopasen/toml-union`) and an [example](/examples/docker-test.sh) of its usage.
## Python usage example
```python
from pathlib import Path
from toml_union import toml_union_process
# run union
toml_union_process(
files=Path('input').glob('*.toml'), # get all *.toml files from examples dir
outfile='output.toml', # set output file path
report='report.json', # path for conflicts report on conflict case
)
```
It combines next files:
```toml
[tool.poetry]
name = "project 1"
version = "1.6.0"
description = "Some words"
authors = ["Me"]
[tool.poetry.dependencies]
"pdfminer.six" = "^20220524"
cmake = "^3.21.1"
other_package = "1"
[tool.poetry.group.dev.dependencies]
autopep8 = "^1.5"
black = "~21.8b0"
ipython = "^8.0"
pylint-django = "^2.3.0"
pytest-django = "^4.5.2"
```
```toml
[tool.poetry]
name = "project 2"
version = "1.6.0"
description = "Some words"
authors = ["Me"]
[tool.poetry.dependencies]
"pdfminer.six" = "^2022333333334"
torch = { version = "1.10.1+cu113", source = "pytorch" }
torchvision = { version = "0.11.2+cu113", source = "pytorch" }
other_package = "2"
[tool.poetry.group.dev.dependencies]
autopep8 = "^1.5"
black = "~21.8b0"
pytest-django = "^4.5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
```
```toml
[tool.poetry]
name = "project 1"
version = "1.6.0"
description = "Some words"
authors = ["Somebody"]
[tool.poetry.dependencies]
"pdfminer.six" = "^20220524"
ansi2html = "^1.7"
beautifulsoup4 = "^4.10.0"
boto3 = "^1.16.56"
chardet = "^4.0.0"
Django = "~3.1"
django-allauth = "^0.51"
django-rosetta = "^0.9.5"
djangorestframework = "3.13.1"
cmake = "~3.21.1"
[tool.poetry.group.dev.dependencies]
autopep8 = ">=1.5.6"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
```
to this:
```toml
[build-system]
build-backend = [ "poetry.core.masonry.api", "poetry.masonry.api",]
requires = [ "poetry-core>=1.0.0", "poetry>=0.12",]
[tool.poetry]
authors = [ "Me", "Somebody",]
description = "Some words"
name = [ "project 1", "project 2",]
version = "1.6.0"
[tool.poetry.dependencies]
"pdfminer.six" = [ "^20220524", "^2022333333334",]
ansi2html = "^1.7"
beautifulsoup4 = "^4.10.0"
boto3 = "^1.16.56"
chardet = "^4.0.0"
cmake = [ "^3.21.1", "~3.21.1",]
Django = "~3.1"
django-allauth = "^0.51"
django-rosetta = "^0.9.5"
djangorestframework = "3.13.1"
other_package = [ "1", "2",]
[tool.poetry.dependencies.torch]
source = "pytorch"
version = "1.10.1+cu113"
[tool.poetry.dependencies.torchvision]
source = "pytorch"
version = "0.11.2+cu113"
[tool.poetry.group.dev.dependencies]
autopep8 = [ "^1.5", ">=1.5.6",]
black = "~21.8b0"
ipython = "^8.0"
pylint-django = "^2.3.0"
pytest-django = "^4.5.2"
```
As u see, some of packages has confict versions. In this case the report file is created and contains the sources of this conflicts:
```json
"pdfminer.six": {
"^20220524": [
"input/file1.toml",
"input/file3.toml"
],
"^2022333333334": [
"input/file2.toml"
]
},
"cmake": {
"^3.21.1": [
"input/file1.toml"
],
"~3.21.1": [
"input/file3.toml"
]
},
"other_package": {
"1": [
"input/file1.toml"
],
"2": [
"input/file2.toml"
]
}
```
## Overrides
There is the ability to override some items in target `*.toml` file. Use syntax:
```python
toml_union_process(
files=Path('input').glob('*.toml'),
outfile='output.toml',
report='report.json',
overrides={
'tool.poetry.name': 'union',
'tool.poetry.version': '12'
}
)
```
In the result u will have:
```toml
[tool.poetry]
name = "union"
version = "12"
```
## CLI
Equivalent CLI command:
```sh
toml-union examples/input/file1.toml examples/input/file2.toml examples/input/file3.toml -o output.toml -r report.json -k tool.poetry.name=union -k tool.poetry.version=12
```
Help message:
```sh
toml-union -h
usage: toml_union.py [-h] [--output OUTFILE] [--unicode-escape] [--report REPORT] [--remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]]] [--key-value KEY=VALUE] [--ckey-value KEY=VALUE] INPUT [INPUT ...]
Combines several toml files to one with conflicts showing
positional arguments:
INPUT input toml files paths
optional arguments:
-h, --help show this help message and exit
--output OUTFILE, -o OUTFILE
output toml file path, empty value means to print to console (default: None)
--unicode-escape, -u whether to try to escape unicode sequences in the outfile, useful when outfile has many slashes and codes (default: False)
--report REPORT, -r REPORT
path to report json on failure (default: None)
--remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]], -e [REMOVE_FIELDS [REMOVE_FIELDS ...]]
Fields to remove. May appear multiple times (default: None)
--key-value KEY=VALUE, -k KEY=VALUE
Add key/value params. May appear multiple times (default: {})
--ckey-value KEY=VALUE, -c KEY=VALUE
Same as --key-value but will be performed only on conflict cases (default: {})
```
Raw data
{
"_id": null,
"home_page": "https://github.com/PasaOpasen/toml-union",
"name": "toml-union",
"maintainer": "Demetry Pascal",
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "toml, merge",
"author": "Demetry Pascal",
"author_email": "qtckpuhdsa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6b/d4/e995562a9f91007e0fa709f03205cc6d411467e2be5b0c586508de6103e7/toml_union-1.0.3.tar.gz",
"platform": null,
"description": "[![PyPI version](https://badge.fury.io/py/toml_union.svg)](https://pypi.org/project/toml_union/)\n[![Downloads](https://pepy.tech/badge/toml_union)](https://pepy.tech/project/toml_union)\n[![Downloads](https://pepy.tech/badge/toml_union/month)](https://pepy.tech/project/toml_union)\n[![Downloads](https://pepy.tech/badge/toml_union/week)](https://pepy.tech/project/toml_union)\n\n\n- [About](#about)\n - [Python usage example](#python-usage-example)\n - [Overrides](#overrides)\n - [CLI](#cli)\n\n\n# About\n\n```sh\npip install toml-union\n```\n\nThis PyPI package is indeed located in one script and combines several `*.toml` files (usially `pyproject.toml`) into one. If it finds some conflicts between items, they will be kept for manual review.\n\nIt has a docker image (`docker pull pasaopasen/toml-union`) and an [example](/examples/docker-test.sh) of its usage.\n\n## Python usage example\n\n```python\nfrom pathlib import Path\n\nfrom toml_union import toml_union_process\n\n# run union\ntoml_union_process(\n files=Path('input').glob('*.toml'), # get all *.toml files from examples dir\n outfile='output.toml', # set output file path\n report='report.json', # path for conflicts report on conflict case\n)\n\n```\n\nIt combines next files:\n\n```toml\n[tool.poetry]\nname = \"project 1\"\nversion = \"1.6.0\"\ndescription = \"Some words\"\nauthors = [\"Me\"]\n\n[tool.poetry.dependencies]\n\"pdfminer.six\" = \"^20220524\"\ncmake = \"^3.21.1\"\nother_package = \"1\"\n\n[tool.poetry.group.dev.dependencies]\nautopep8 = \"^1.5\"\nblack = \"~21.8b0\"\nipython = \"^8.0\"\npylint-django = \"^2.3.0\"\npytest-django = \"^4.5.2\"\n```\n\n```toml\n[tool.poetry]\nname = \"project 2\"\nversion = \"1.6.0\"\ndescription = \"Some words\"\nauthors = [\"Me\"]\n\n[tool.poetry.dependencies]\n\"pdfminer.six\" = \"^2022333333334\"\ntorch = { version = \"1.10.1+cu113\", source = \"pytorch\" }\ntorchvision = { version = \"0.11.2+cu113\", source = \"pytorch\" }\nother_package = \"2\"\n\n[tool.poetry.group.dev.dependencies]\nautopep8 = \"^1.5\"\nblack = \"~21.8b0\"\npytest-django = \"^4.5.2\"\n\n[build-system]\nrequires = [\"poetry-core>=1.0.0\"]\nbuild-backend = \"poetry.core.masonry.api\"\n```\n\n```toml\n[tool.poetry]\nname = \"project 1\"\nversion = \"1.6.0\"\ndescription = \"Some words\"\nauthors = [\"Somebody\"]\n\n[tool.poetry.dependencies]\n\"pdfminer.six\" = \"^20220524\"\nansi2html = \"^1.7\"\nbeautifulsoup4 = \"^4.10.0\"\nboto3 = \"^1.16.56\"\nchardet = \"^4.0.0\"\nDjango = \"~3.1\"\ndjango-allauth = \"^0.51\"\ndjango-rosetta = \"^0.9.5\"\ndjangorestframework = \"3.13.1\"\ncmake = \"~3.21.1\"\n\n[tool.poetry.group.dev.dependencies]\nautopep8 = \">=1.5.6\"\n\n[build-system]\nrequires = [\"poetry>=0.12\"]\nbuild-backend = \"poetry.masonry.api\"\n```\n\nto this:\n```toml\n[build-system]\nbuild-backend = [ \"poetry.core.masonry.api\", \"poetry.masonry.api\",]\nrequires = [ \"poetry-core>=1.0.0\", \"poetry>=0.12\",]\n\n[tool.poetry]\nauthors = [ \"Me\", \"Somebody\",]\ndescription = \"Some words\"\nname = [ \"project 1\", \"project 2\",]\nversion = \"1.6.0\"\n\n[tool.poetry.dependencies]\n\"pdfminer.six\" = [ \"^20220524\", \"^2022333333334\",]\nansi2html = \"^1.7\"\nbeautifulsoup4 = \"^4.10.0\"\nboto3 = \"^1.16.56\"\nchardet = \"^4.0.0\"\ncmake = [ \"^3.21.1\", \"~3.21.1\",]\nDjango = \"~3.1\"\ndjango-allauth = \"^0.51\"\ndjango-rosetta = \"^0.9.5\"\ndjangorestframework = \"3.13.1\"\nother_package = [ \"1\", \"2\",]\n\n[tool.poetry.dependencies.torch]\nsource = \"pytorch\"\nversion = \"1.10.1+cu113\"\n\n[tool.poetry.dependencies.torchvision]\nsource = \"pytorch\"\nversion = \"0.11.2+cu113\"\n\n[tool.poetry.group.dev.dependencies]\nautopep8 = [ \"^1.5\", \">=1.5.6\",]\nblack = \"~21.8b0\"\nipython = \"^8.0\"\npylint-django = \"^2.3.0\"\npytest-django = \"^4.5.2\"\n```\n\nAs u see, some of packages has confict versions. In this case the report file is created and contains the sources of this conflicts:\n```json\n\"pdfminer.six\": {\n \"^20220524\": [\n \"input/file1.toml\",\n \"input/file3.toml\"\n ],\n \"^2022333333334\": [\n \"input/file2.toml\"\n ]\n},\n\"cmake\": {\n \"^3.21.1\": [\n \"input/file1.toml\"\n ],\n \"~3.21.1\": [\n \"input/file3.toml\"\n ]\n},\n\"other_package\": {\n \"1\": [\n \"input/file1.toml\"\n ],\n \"2\": [\n \"input/file2.toml\"\n ]\n}\n```\n\n## Overrides\n\nThere is the ability to override some items in target `*.toml` file. Use syntax:\n\n```python\ntoml_union_process(\n files=Path('input').glob('*.toml'),\n outfile='output.toml',\n report='report.json',\n\n overrides={\n 'tool.poetry.name': 'union',\n 'tool.poetry.version': '12'\n }\n)\n```\n\nIn the result u will have:\n```toml\n[tool.poetry]\nname = \"union\"\nversion = \"12\"\n```\n\n## CLI\n\nEquivalent CLI command:\n```sh\ntoml-union examples/input/file1.toml examples/input/file2.toml examples/input/file3.toml -o output.toml -r report.json -k tool.poetry.name=union -k tool.poetry.version=12\n```\n\nHelp message:\n\n```sh\ntoml-union -h\n\nusage: toml_union.py [-h] [--output OUTFILE] [--unicode-escape] [--report REPORT] [--remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]]] [--key-value KEY=VALUE] [--ckey-value KEY=VALUE] INPUT [INPUT ...]\n\nCombines several toml files to one with conflicts showing\n\npositional arguments:\n INPUT input toml files paths\n\noptional arguments:\n -h, --help show this help message and exit\n --output OUTFILE, -o OUTFILE\n output toml file path, empty value means to print to console (default: None)\n --unicode-escape, -u whether to try to escape unicode sequences in the outfile, useful when outfile has many slashes and codes (default: False)\n --report REPORT, -r REPORT\n path to report json on failure (default: None)\n --remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]], -e [REMOVE_FIELDS [REMOVE_FIELDS ...]]\n Fields to remove. May appear multiple times (default: None)\n --key-value KEY=VALUE, -k KEY=VALUE\n Add key/value params. May appear multiple times (default: {})\n --ckey-value KEY=VALUE, -c KEY=VALUE\n Same as --key-value but will be performed only on conflict cases (default: {})\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utils to merge *.toml files with conflicts highlighting",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/PasaOpasen/toml-union"
},
"split_keywords": [
"toml",
" merge"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "adcf79b88083306aec6d514a20b54036a396f6bb785c85883703ed04fee0da61",
"md5": "d9777e7c1d5e09fbf9d494222c9515a6",
"sha256": "ebe3090dd78c6c6dadca9d25968960aafe1977598c18c06716d1f2da16b9c286"
},
"downloads": -1,
"filename": "toml_union-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d9777e7c1d5e09fbf9d494222c9515a6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10619,
"upload_time": "2024-04-24T19:48:41",
"upload_time_iso_8601": "2024-04-24T19:48:41.177359Z",
"url": "https://files.pythonhosted.org/packages/ad/cf/79b88083306aec6d514a20b54036a396f6bb785c85883703ed04fee0da61/toml_union-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6bd4e995562a9f91007e0fa709f03205cc6d411467e2be5b0c586508de6103e7",
"md5": "10b2948e5beb6cc279a12c8301e7499b",
"sha256": "1432676e96d2ae046ac1368e9a3e841e10a09ebbd564ff99a3011575eec39333"
},
"downloads": -1,
"filename": "toml_union-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "10b2948e5beb6cc279a12c8301e7499b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11722,
"upload_time": "2024-04-24T19:48:42",
"upload_time_iso_8601": "2024-04-24T19:48:42.677425Z",
"url": "https://files.pythonhosted.org/packages/6b/d4/e995562a9f91007e0fa709f03205cc6d411467e2be5b0c586508de6103e7/toml_union-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-24 19:48:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PasaOpasen",
"github_project": "toml-union",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "toml",
"specs": []
}
],
"lcname": "toml-union"
}