htmlcmp 1.2.2__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/PKG-INFO +1 -1
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/pyproject.toml +1 -1
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/html_render_diff.py +18 -5
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/PKG-INFO +1 -1
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/README.md +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/setup.cfg +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/__init__.py +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/common.py +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/compare_output.py +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/compare_output_server.py +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp/tidy_output.py +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/SOURCES.txt +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/dependency_links.txt +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/entry_points.txt +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/requires.txt +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/src/htmlcmp.egg-info/top_level.txt +0 -0
- {htmlcmp-1.2.2 → htmlcmp-1.2.3}/tests/test_html_render_diff.py +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import shutil
|
|
5
4
|
import sys
|
|
6
5
|
import argparse
|
|
7
6
|
import io
|
|
@@ -36,8 +35,13 @@ def screenshot(browser: webdriver.Remote, url: str) -> Image.Image:
|
|
|
36
35
|
|
|
37
36
|
target_find_by = By.TAG_NAME
|
|
38
37
|
target = "body"
|
|
38
|
+
loaded_page_settling_time = 0
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
# TODO for pdf2htmlex the second screenshot sometimes fades in from white... not sure why, but a sleep solves it
|
|
41
|
+
if "poppler" in url:
|
|
42
|
+
loaded_page_settling_time = 0.3
|
|
43
|
+
|
|
44
|
+
web_driver_wait = WebDriverWait(browser, 10)
|
|
41
45
|
web_driver_wait.until(
|
|
42
46
|
expected_conditions.presence_of_element_located((target_find_by, target))
|
|
43
47
|
)
|
|
@@ -45,7 +49,9 @@ def screenshot(browser: webdriver.Remote, url: str) -> Image.Image:
|
|
|
45
49
|
lambda driver: driver.execute_script("return document.readyState") == "complete"
|
|
46
50
|
)
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
time.sleep(loaded_page_settling_time)
|
|
53
|
+
|
|
54
|
+
png = browser.get_full_page_screenshot_as_png()
|
|
49
55
|
return Image.open(io.BytesIO(png))
|
|
50
56
|
|
|
51
57
|
|
|
@@ -74,15 +80,22 @@ def get_browser(
|
|
|
74
80
|
|
|
75
81
|
|
|
76
82
|
def html_render_diff(
|
|
77
|
-
a: str | Path,
|
|
83
|
+
a: str | Path,
|
|
84
|
+
b: str | Path,
|
|
85
|
+
browser: webdriver.Remote,
|
|
86
|
+
browser_b: webdriver.Remote = None,
|
|
78
87
|
) -> tuple[Image.Image, tuple[Image.Image, Image.Image]]:
|
|
79
88
|
if not isinstance(a, (str, Path)) or not isinstance(b, (str, Path)):
|
|
80
89
|
raise TypeError("Both a and b must be str or Path instances")
|
|
81
90
|
if not isinstance(browser, webdriver.Remote):
|
|
82
91
|
raise TypeError(f"Expected webdriver.Remote, got {type(browser)}")
|
|
92
|
+
if browser_b is None:
|
|
93
|
+
browser_b = browser
|
|
94
|
+
elif not isinstance(browser_b, webdriver.Remote):
|
|
95
|
+
raise TypeError(f"Expected webdriver.Remote, got {type(browser_b)}")
|
|
83
96
|
|
|
84
97
|
image_a = screenshot(browser, to_url(a))
|
|
85
|
-
image_b = screenshot(
|
|
98
|
+
image_b = screenshot(browser_b, to_url(b))
|
|
86
99
|
|
|
87
100
|
image_a = image_a.convert("RGB")
|
|
88
101
|
image_b = image_b.convert("RGB")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|