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:
    ...

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.5.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

moreorless-0.5.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moreorless-0.5.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for moreorless-0.5.0.tar.gz
Algorithm Hash digest
SHA256 560a04f85006fccd74feaa4b6213a446392ff7b5ec0194a5464b6c30f182fa33
MD5 2ea1fab53d8dc13b97dd16b8d9a4160e
BLAKE2b-256 8d852e4999ac4a21ab3c5f31e2a48e0989a80be3afc512a7983e3253615983d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moreorless-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for moreorless-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66228870cd2f14bad5c3c3780aa71e29d3b2d9b5a01c03bfbf105efd4f668ecf
MD5 b449b3f28f3999fa5ffac4ddda1728b8
BLAKE2b-256 fa2e9ea80ca55b73530b7639c6f146a58f636ddfe5a852ad467a44fe3e80d809

See more details on using hashes here.

Supported by

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