Registry / serialization / moreorless

moreorless

JSON →
library0.6.0pypypi✓ verified 24d ago

Moreorless is a thin Python wrapper around `difflib.unified_diff` designed to simplify its usage and address common edge cases, such as the "No newline at eof" issue. It provides a more user-friendly interface for generating unified diffs, applying patches, and producing colorized diff output. The current version is 0.5.0, with an irregular release cadence based on contributions and feature enhancements.

pip install moreorless
INSTALL
IMPORT
SIG · MOREORLESS
M
moreorless
serializationpythonv0.6.0
Install
1.5s avg
Import
22ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.026s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.018s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

unified_diff
from moreorless import unified_diff
apply_single_file
from moreorless.patch import apply_single_file
echo_color_unified_diff
from moreorless.click import echo_color_unified_diff
from moreorless import echo_color_unified_diff
Colorized output functions are in the 'click' submodule.
combined_diff
from moreorless.combined import combined_diff

This example demonstrates how to generate a raw unified diff string using `unified_diff` and how to print a colorized diff to the console using `echo_color_unified_diff`. The `filename` arguments are used in the diff header.

from moreorless import unified_diff from moreorless.click import echo_color_unified_diff old_text = """Line 1\nLine 2\nLine 3 - original\nLine 4\n""" new_text = """Line 1\nLine 2 - modified\nLine 3 - changed\nLine 5 - new\n""" # Get a raw unified diff string diff_string = unified_diff(old_text, new_text, 'old_file.txt', 'new_file.txt') print("\n--- Raw Unified Diff ---") print(diff_string) # Or print a colorized diff directly to stdout (requires 'click' package) print("\n--- Colorized Diff (using click) ---") echo_color_unified_diff(old_text, new_text, 'old_file.txt', 'new_file.txt')
moreorless --version
Debug
Known issues
gotchaWhile `moreorless` simplifies `difflib.unified_diff`, it is still a wrapper. For highly complex or performance-critical diffing scenarios, understanding the underlying `difflib` module might be beneficial.
fix
Consult Python's `difflib` documentation for advanced use cases or deep customization.
affects: All
gotchaThe `echo_color_unified_diff` function (and other color-related utilities) internally uses the `click` library for terminal output. While `click` is a required dependency, users unfamiliar with `click` might find the integration surprising or encounter issues if their terminal environment doesn't support ANSI escape codes.
fix
Ensure your terminal supports ANSI escape codes for colorized output. If you only need the diff string, use `unified_diff` directly which does not involve `click`'s output formatting.
affects: All
deprecatedThe `moreorless` library is relatively small with limited community contributions (few stars, forks). While actively maintained by the author, major feature additions or rapid bug fixes might not occur as quickly as with larger, more widely adopted libraries.
fix
Consider contributing to the project or opening issues for bugs/feature requests to help drive development. For enterprise-grade needs, evaluate its fit carefully.
affects: All
breakingThe `combined_diff` functionality was introduced in version `0.5.0`. Attempts to use `moreorless.combined.combined_diff` in versions prior to `0.5.0` will result in an `ImportError` or `AttributeError`.
fix
Upgrade to `moreorless>=0.5.0` to use the combined diff feature.
affects: <0.5.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'moreorless'
The 'moreorless' library has not been installed in your Python environment or is not accessible on the Python path.
fix
Install the package using pip: `pip install moreorless`
moreorless.patch.PatchException: Invalid patch format
The patch string provided to 'moreorless.patch.apply_single_file' is malformed, does not apply cleanly to the target content, or contains syntax errors.
fix
Ensure the patch string is a valid unified diff format and corresponds accurately to the changes between the original and modified content. Verify the integrity and correctness of the patch content.
TypeError: moreorless.unified_diff() missing 1 required positional argument: 'bstr'
A function like 'moreorless.unified_diff' or 'moreorless.patch.apply_single_file' was called with an incorrect number of arguments, typically missing a required positional argument.
fix
Review the function's signature and provide all necessary arguments. For 'unified_diff', ensure you provide 'astr' (original string), 'bstr' (new string), and 'filename' (source filename for context).
Upgrade
Version history
0.6.0latest on PyPI · released May 12, 2026
Audit
Dependencies
clickrequiredUsed for command-line utilities and colorized diff output.
Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
moreorless — pip install moreorless · libregistry