htmlcmp 1.0.2__tar.gz → 1.0.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.0.2 → htmlcmp-1.0.3}/PKG-INFO +1 -1
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/pyproject.toml +1 -1
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/setup.py +1 -1
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/html_render_diff.py +7 -8
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/tidy_output.py +33 -25
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp.egg-info/PKG-INFO +1 -1
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/README.md +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/setup.cfg +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/__init__.py +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/common.py +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/compare_output.py +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp/compare_output_server.py +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp.egg-info/SOURCES.txt +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp.egg-info/dependency_links.txt +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp.egg-info/entry_points.txt +0 -0
- {htmlcmp-1.0.2 → htmlcmp-1.0.3}/src/htmlcmp.egg-info/top_level.txt +0 -0
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import os
|
|
5
4
|
import sys
|
|
6
5
|
import argparse
|
|
7
6
|
import io
|
|
8
7
|
import time
|
|
8
|
+
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
from PIL import Image, ImageChops
|
|
11
11
|
from selenium import webdriver
|
|
12
12
|
from selenium.webdriver.common.by import By
|
|
13
13
|
from selenium.webdriver.support import expected_conditions
|
|
14
14
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
15
|
-
import pathlib
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
def to_url(
|
|
19
|
-
if
|
|
20
|
-
return
|
|
21
|
-
return
|
|
17
|
+
def to_url(path):
|
|
18
|
+
if path.is_file():
|
|
19
|
+
return path.as_uri()
|
|
20
|
+
return path
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
def screenshot(browser, url):
|
|
@@ -77,8 +76,8 @@ def html_render_diff(a, b, browser):
|
|
|
77
76
|
|
|
78
77
|
def main():
|
|
79
78
|
parser = argparse.ArgumentParser()
|
|
80
|
-
parser.add_argument("a")
|
|
81
|
-
parser.add_argument("b")
|
|
79
|
+
parser.add_argument("a", type=Path)
|
|
80
|
+
parser.add_argument("b", type=Path)
|
|
82
81
|
parser.add_argument(
|
|
83
82
|
"--driver", choices=["chrome", "firefox", "phantomjs"], default="firefox"
|
|
84
83
|
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import os
|
|
5
4
|
import sys
|
|
6
5
|
import argparse
|
|
7
6
|
import json
|
|
8
7
|
import subprocess
|
|
9
8
|
import shlex
|
|
9
|
+
from pathlib import Path
|
|
10
10
|
|
|
11
11
|
from htmlcmp.common import bcolors
|
|
12
12
|
|
|
@@ -20,35 +20,39 @@ def tidy_json(path):
|
|
|
20
20
|
return 1
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def tidy_html(path):
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
def tidy_html(path, html_tidy_config=None):
|
|
24
|
+
if html_tidy_config:
|
|
25
|
+
cmd = shlex.split(f'tidy -config "{html_tidy_config.resolve()}" -q "{path}"')
|
|
26
|
+
else:
|
|
27
|
+
cmd = shlex.split(f'tidy -q "{path}"')
|
|
28
|
+
result = subprocess.run(
|
|
29
|
+
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
|
|
26
30
|
)
|
|
27
|
-
cmd = shlex.split(f'tidy -config "{config_path}" -q "{path}"')
|
|
28
|
-
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
29
31
|
if result.returncode == 1:
|
|
32
|
+
print(result.stdout)
|
|
30
33
|
return 1
|
|
31
34
|
if result.returncode > 1:
|
|
35
|
+
print(result.stdout)
|
|
32
36
|
return 2
|
|
33
37
|
return 0
|
|
34
38
|
|
|
35
39
|
|
|
36
|
-
def tidy_file(path):
|
|
37
|
-
if path.
|
|
40
|
+
def tidy_file(path, html_tidy_config=None):
|
|
41
|
+
if path.suffix == ".json":
|
|
38
42
|
return tidy_json(path)
|
|
39
|
-
elif path.
|
|
40
|
-
return tidy_html(path)
|
|
43
|
+
elif path.suffix == ".html":
|
|
44
|
+
return tidy_html(path, html_tidy_config=html_tidy_config)
|
|
41
45
|
|
|
42
46
|
|
|
43
47
|
def tidyable_file(path):
|
|
44
|
-
if path.
|
|
48
|
+
if path.suffix == ".json":
|
|
45
49
|
return True
|
|
46
|
-
if path.
|
|
50
|
+
if path.suffix == ".html":
|
|
47
51
|
return True
|
|
48
52
|
return False
|
|
49
53
|
|
|
50
54
|
|
|
51
|
-
def tidy_dir(path, level=0, prefix=""):
|
|
55
|
+
def tidy_dir(path, level=0, prefix="", html_tidy_config=None):
|
|
52
56
|
prefix_file = prefix + "├── "
|
|
53
57
|
if level == 0:
|
|
54
58
|
print(f"tidy dir {path}")
|
|
@@ -58,15 +62,13 @@ def tidy_dir(path, level=0, prefix=""):
|
|
|
58
62
|
"error": [],
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
items = [
|
|
62
|
-
files = sorted(
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
dirs = sorted([path for path in items if os.path.isdir(path)])
|
|
65
|
+
items = [path / name for name in path.iterdir()]
|
|
66
|
+
files = sorted([path for path in items if path.is_file() and tidyable_file(path)])
|
|
67
|
+
dirs = sorted([path for path in items if path.is_dir()])
|
|
66
68
|
|
|
67
|
-
for filename in [
|
|
68
|
-
filepath =
|
|
69
|
-
tidy = tidy_file(filepath)
|
|
69
|
+
for filename in [path.name for path in files]:
|
|
70
|
+
filepath = path / filename
|
|
71
|
+
tidy = tidy_file(filepath, html_tidy_config=html_tidy_config)
|
|
70
72
|
if tidy == 0:
|
|
71
73
|
print(f"{prefix_file}{bcolors.OKGREEN}{filename} ✓{bcolors.ENDC}")
|
|
72
74
|
elif tidy == 1:
|
|
@@ -76,10 +78,13 @@ def tidy_dir(path, level=0, prefix=""):
|
|
|
76
78
|
print(f"{prefix_file}{bcolors.FAIL}{filename} ✘{bcolors.ENDC}")
|
|
77
79
|
result["error"].append(filepath)
|
|
78
80
|
|
|
79
|
-
for dirname in [
|
|
81
|
+
for dirname in [path.name for path in dirs]:
|
|
80
82
|
print(prefix + "├── " + dirname)
|
|
81
83
|
subresult = tidy_dir(
|
|
82
|
-
|
|
84
|
+
path / dirname,
|
|
85
|
+
level=level + 1,
|
|
86
|
+
prefix=prefix + "│ ",
|
|
87
|
+
html_tidy_config=html_tidy_config,
|
|
83
88
|
)
|
|
84
89
|
result["warning"].extend(subresult["warning"])
|
|
85
90
|
result["error"].extend(subresult["error"])
|
|
@@ -89,10 +94,13 @@ def tidy_dir(path, level=0, prefix=""):
|
|
|
89
94
|
|
|
90
95
|
def main():
|
|
91
96
|
parser = argparse.ArgumentParser()
|
|
92
|
-
parser.add_argument("
|
|
97
|
+
parser.add_argument("path", type=Path, help="Path to directory to tidy")
|
|
98
|
+
parser.add_argument(
|
|
99
|
+
"--html-tidy-config", type=Path, help="Path to tidy config file"
|
|
100
|
+
)
|
|
93
101
|
args = parser.parse_args()
|
|
94
102
|
|
|
95
|
-
result = tidy_dir(args.
|
|
103
|
+
result = tidy_dir(args.path, html_tidy_config=args.html_tidy_config)
|
|
96
104
|
if result["error"]:
|
|
97
105
|
return 1
|
|
98
106
|
|
|
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
|