Skip to main content

Python diff wrapper

Project description

moreorless

This is a thin wrapper around difflib.unified_diff that Does The Right Thing for "No newline at eof". The args are also simplified compared to difflib:

moreorless.unified_diff(
    astr: str,
    bstr: str,
    filename: str,
    n: int = 3,
) -> str:
    ...

# raises moreorless.patch.PatchException
moreorless.patch.apply_single_file(
    contents: str,
    patch: str,
    allow_offsets: bool = True,
) -> str:
    ...

# uses click to write to stdout with colors
moreorless.click.echo_color_unified_diff(
    astr: str,
    bstr: str,
    filename: str,
    n: int = 3
) -> None:
    ...

# if you want to use unified_diff yourself first (e.g. in another process)
moreorless.click.echo_color_precomputed_diff(
    diff: str,
) -> None:
    ...

# if you want to produce a combined (merge) diff:
moreorless.combined.combined_diff(
    [astr, bstr], [cstr]
) -> str:
    ...

Version Compat

This library is compatible with Python 3.9+, but should be linted under the newest stable version.

Versioning

This library follows meanver, which basically means semver along with a promise to rename when the major version changes.

Install the optional cli extra if you want the colored diff helpers:

pip install moreorless[cli]

License

moreorless is copyright Tim Hatch, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

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

moreorless-0.6.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moreorless-0.6.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file moreorless-0.6.0.tar.gz.

File metadata

  • Download URL: moreorless-0.6.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moreorless-0.6.0.tar.gz
Algorithm Hash digest
SHA256 175e8afa824006c4356353d97b1cc9699a6ef68a851e0859257cde8d00e88a64
MD5 f2dc39e8b1c9d54461dcbba25506becf
BLAKE2b-256 66cd388ad4893c29cc8d54bc35ef6d699f747c7602132361f289dd28ae614448

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreorless-0.6.0.tar.gz:

Publisher: build.yml on thatch/moreorless

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file moreorless-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: moreorless-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for moreorless-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b00997fee924ab86f2e135ba08e4d70d3295a7226d3d083a5c69ec4e2a9e9e83
MD5 9367c958205b72ba0f0f7d7bae6fa8f0
BLAKE2b-256 0341503e35f695f45e2f07c623d9540377761beebf5a3ecb2322769b98f284d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreorless-0.6.0-py3-none-any.whl:

Publisher: build.yml on thatch/moreorless

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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