Skip to main content

No project description provided

Project description

tomlpatch

Do you want to patch your toml file structurally like modifying a nested python dictionary? This is a tool for you.

Description

Sometimes, you want to edit/patch a toml file, but you don't want to use the diff between two source files to patch the toml file since it may introduce conflicts that requires human intervention to resolve. For example, Cargo.toml is used by Rust projects, and this tool can be used to patch the Cargo.toml file with an external JSON file that contains the structural patch information so that you don't need to manually resolve the Cargo.toml file.

Installation

pip install tomlpatch

Usage

tomlpatch original_toml_file patch_json_file

Example

Suppose you have a Cargo.toml file like this:

[package]
name = "my_package"
version = "0.0.1"

liberssl = { version = "0.10.42", default-features = false, features=["vendered"] }
sources = ["s1", "s2"]

And you want to patch the Cargo.toml file with a JSON file like this:

{
  "patch": {
    "package.version": "0.0.2",
    "package.liberssl.features": null
  },
  "extend": {
    "package.sources": ["s4", "s5"]
  }
}

Then you can use the following command to patch the Cargo.toml file:

tomlpatch Cargo.toml patch.json

After the patch, the Cargo.toml file will be like this:

[package]
name = "my_package"
version = "0.0.2"
sources = [
    "s1",
    "s2",
    "s4",
    "s5",
]

[package.liberssl]
version = "0.10.42"
default-features = false

TODO

  • Switch to tomkit for style preserving patching

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomlpatch-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

tomlpatch-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file tomlpatch-0.1.1.tar.gz.

File metadata

  • Download URL: tomlpatch-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for tomlpatch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2ce111829846d3302cb65c05feaa6265d5854d8c54c8e2451b40be5e5be2908f
MD5 204c59ebd3e95d72195d238ba4f6c009
BLAKE2b-256 7645358fb60ff9a54109d1715be8ea958004f77f1bf5666f6e74ec1ab9191d3f

See more details on using hashes here.

File details

Details for the file tomlpatch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tomlpatch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for tomlpatch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3f2f91355228696bee6ae3a7f5d655e0cee97339fb600f1494dcfba2b40314
MD5 7ea441b615923a43855099893bb5385b
BLAKE2b-256 758aec48907da47202a589e81a475cc9cbfc77ff3a05645d3911561dc841bbc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page