Skip to content

Commit 3eb0b8b

Browse files
authored
Update fast_diff_match_patch (#126)
The `diff_match_patch_python` package was renamed to `fast_diff_match_patch`. This updates it and switches to the new name (it was out-of-date enough to trigger deprecation warnings on some Python versions). I also fixed a typo in the version constraints for html5-parser while doing this.
1 parent 3736113 commit 3eb0b8b

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

docs/source/release-history.rst

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Release History
33
===============
44

5+
In Development
6+
--------------
7+
8+
- Updates the diff-match-patch implementation we rely on for simple text diffs to `fast_diff_match_patch v2.x <https://pypi.org/project/fast-diff-match-patch/>`_. (:issue:`126`)
9+
10+
- Fix misconfigured dependency requirements for html5-parser. This should have no user impact, since there are no releases (yet) in the version range we were accidentally allowing for. (:issue:`126`)
11+
12+
513
Version 0.1.3 (2022-04-18)
614
--------------------------
715

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
# It only exists to keep the list of dependencies in a separate file from
99
# setup.py.
1010
beautifulsoup4 >=4.9.0,<5
11-
diff_match_patch_python >=1.0.2,<2
12-
html5-parser >=0.4.0,<5 --no-binary lxml
11+
fast_diff_match_patch >=2.0.1,<3
12+
html5-parser >=0.4.0,<0.5 --no-binary lxml
1313
lxml >=4.5.0,<5

web_monitoring_diff/basic_diffs.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from bs4 import Comment
2-
from diff_match_patch import diff, diff_bytes
2+
from fast_diff_match_patch import diff
33
import html5_parser
44
import re
55
import sys
@@ -58,11 +58,9 @@ def side_by_side_text(a_text, b_text):
5858

5959

6060
def compute_dmp_diff(a_text, b_text, timelimit=4):
61-
if (isinstance(a_text, str) and isinstance(b_text, str)):
62-
changes = diff(a_text, b_text, checklines=False, timelimit=timelimit, cleanup_semantic=True, counts_only=False)
63-
elif (isinstance(a_text, bytes) and isinstance(b_text, bytes)):
64-
changes = diff_bytes(a_text, b_text, checklines=False, timelimit=timelimit, cleanup_semantic=True,
65-
counts_only=False)
61+
if (isinstance(a_text, (str, bytes)) and isinstance(b_text, (str, bytes))):
62+
changes = diff(a_text, b_text, checklines=False, timelimit=timelimit, cleanup="Semantic",
63+
counts_only=False)
6664
else:
6765
raise TypeError("Both the texts should be either of type 'str' or 'bytes'.")
6866

0 commit comments

Comments
 (0)