htmlcmp 1.0.1__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.3/PKG-INFO ADDED
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: htmlcmp
3
+ Version: 1.0.3
4
+ Summary: Compare HTML files by rendered output
5
+ Home-page: https://github.com/opendocument-app/compare-html
6
+ Author: Andreas Stefl
7
+ Author-email: stefl.andreas@gmail.com
8
+ Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
9
+ Project-URL: homepage, https://opendocument.app/
10
+ Project-URL: source, https://github.com/opendocument-app/compare-html
11
+ Project-URL: download, https://pypi.org/project/pyodr/#files
12
+ Project-URL: tracker, https://github.com/opendocument-app/compare-html/issues
13
+ Project-URL: release notes, https://github.com/opendocument-app/compare-html/releases
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ Dynamic: author-email
17
+ Dynamic: home-page
18
+ Dynamic: requires-python
19
+
20
+ # htmlcmp
21
+
22
+ Tool to compare (generated) HTML files visually and automatically using Selenium.
23
+
24
+ Provides various entry points to run:
25
+ - `compare-html` is a CLI tool to compare two directory structures containing HTML files
26
+ - `compare-html-server` starts a webserver and allows to inspect differences manually
27
+ - `html-render-diff` renders two HTML files and produces images
28
+ - `html-tidy` allows to run HTML tidy on a directory
29
+
30
+ Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
31
+
32
+ ## Install via PyPI
33
+
34
+ ```bash
35
+ pip install htmlcmp
36
+ ```
37
+
38
+ ## Download and run the docker image
39
+
40
+ ```bash
41
+ docker pull ghcr.io/opendocument-app/odr_core_test
42
+ ```
43
+
44
+ ```bash
45
+ docker run -ti \
46
+ -v $(pwd):/repo \
47
+ -p 8000:8000 \
48
+ ghcr.io/opendocument-app/odr_core_test \
49
+ compare-html-server /repo/REFERENCE /repo/MONITORED --compare --driver firefox --port 8000
50
+ ```
51
+
52
+ ## Manually build the docker image
53
+
54
+ ```bash
55
+ docker build --tag odr_core_test test/docker
56
+ ```
@@ -0,0 +1,37 @@
1
+ # htmlcmp
2
+
3
+ Tool to compare (generated) HTML files visually and automatically using Selenium.
4
+
5
+ Provides various entry points to run:
6
+ - `compare-html` is a CLI tool to compare two directory structures containing HTML files
7
+ - `compare-html-server` starts a webserver and allows to inspect differences manually
8
+ - `html-render-diff` renders two HTML files and produces images
9
+ - `html-tidy` allows to run HTML tidy on a directory
10
+
11
+ Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
12
+
13
+ ## Install via PyPI
14
+
15
+ ```bash
16
+ pip install htmlcmp
17
+ ```
18
+
19
+ ## Download and run the docker image
20
+
21
+ ```bash
22
+ docker pull ghcr.io/opendocument-app/odr_core_test
23
+ ```
24
+
25
+ ```bash
26
+ docker run -ti \
27
+ -v $(pwd):/repo \
28
+ -p 8000:8000 \
29
+ ghcr.io/opendocument-app/odr_core_test \
30
+ compare-html-server /repo/REFERENCE /repo/MONITORED --compare --driver firefox --port 8000
31
+ ```
32
+
33
+ ## Manually build the docker image
34
+
35
+ ```bash
36
+ docker build --tag odr_core_test test/docker
37
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "htmlcmp"
3
- version = "1.0.1"
3
+ version = "1.0.3"
4
4
  description = "Compare HTML files by rendered output"
5
5
  classifiers = []
6
6
  authors = [
@@ -7,7 +7,7 @@ long_description = (this_directory / "README.md").read_text()
7
7
 
8
8
  setup(
9
9
  name="htmlcmp",
10
- version="1.0.1",
10
+ version="1.0.3",
11
11
  author="Andreas Stefl",
12
12
  author_email="stefl.andreas@gmail.com",
13
13
  description="Compare HTML files by rendered output",
@@ -8,8 +8,9 @@ import json
8
8
  import threading
9
9
  import filecmp
10
10
  from concurrent.futures import ThreadPoolExecutor
11
- from html_render_diff import get_browser, html_render_diff
12
- from common import bcolors
11
+
12
+ from htmlcmp.html_render_diff import get_browser, html_render_diff
13
+ from htmlcmp.common import bcolors
13
14
 
14
15
 
15
16
  class Config:
@@ -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(something):
19
- if os.path.isfile(something):
20
- return pathlib.Path(os.path.abspath(something)).as_uri()
21
- return something
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
  )
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys
5
+ import argparse
6
+ import json
7
+ import subprocess
8
+ import shlex
9
+ from pathlib import Path
10
+
11
+ from htmlcmp.common import bcolors
12
+
13
+
14
+ def tidy_json(path):
15
+ try:
16
+ with open(path, "r") as f:
17
+ json.load(f)
18
+ return 0
19
+ except ValueError:
20
+ return 1
21
+
22
+
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
30
+ )
31
+ if result.returncode == 1:
32
+ print(result.stdout)
33
+ return 1
34
+ if result.returncode > 1:
35
+ print(result.stdout)
36
+ return 2
37
+ return 0
38
+
39
+
40
+ def tidy_file(path, html_tidy_config=None):
41
+ if path.suffix == ".json":
42
+ return tidy_json(path)
43
+ elif path.suffix == ".html":
44
+ return tidy_html(path, html_tidy_config=html_tidy_config)
45
+
46
+
47
+ def tidyable_file(path):
48
+ if path.suffix == ".json":
49
+ return True
50
+ if path.suffix == ".html":
51
+ return True
52
+ return False
53
+
54
+
55
+ def tidy_dir(path, level=0, prefix="", html_tidy_config=None):
56
+ prefix_file = prefix + "├── "
57
+ if level == 0:
58
+ print(f"tidy dir {path}")
59
+
60
+ result = {
61
+ "warning": [],
62
+ "error": [],
63
+ }
64
+
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()])
68
+
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)
72
+ if tidy == 0:
73
+ print(f"{prefix_file}{bcolors.OKGREEN}{filename} ✓{bcolors.ENDC}")
74
+ elif tidy == 1:
75
+ print(f"{prefix_file}{bcolors.WARNING}{filename} ✓{bcolors.ENDC}")
76
+ result["warning"].append(filepath)
77
+ elif tidy > 1:
78
+ print(f"{prefix_file}{bcolors.FAIL}{filename} ✘{bcolors.ENDC}")
79
+ result["error"].append(filepath)
80
+
81
+ for dirname in [path.name for path in dirs]:
82
+ print(prefix + "├── " + dirname)
83
+ subresult = tidy_dir(
84
+ path / dirname,
85
+ level=level + 1,
86
+ prefix=prefix + "│ ",
87
+ html_tidy_config=html_tidy_config,
88
+ )
89
+ result["warning"].extend(subresult["warning"])
90
+ result["error"].extend(subresult["error"])
91
+
92
+ return result
93
+
94
+
95
+ def main():
96
+ parser = argparse.ArgumentParser()
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
+ )
101
+ args = parser.parse_args()
102
+
103
+ result = tidy_dir(args.path, html_tidy_config=args.html_tidy_config)
104
+ if result["error"]:
105
+ return 1
106
+
107
+ return 0
108
+
109
+
110
+ if __name__ == "__main__":
111
+ sys.exit(main())
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: htmlcmp
3
+ Version: 1.0.3
4
+ Summary: Compare HTML files by rendered output
5
+ Home-page: https://github.com/opendocument-app/compare-html
6
+ Author: Andreas Stefl
7
+ Author-email: stefl.andreas@gmail.com
8
+ Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
9
+ Project-URL: homepage, https://opendocument.app/
10
+ Project-URL: source, https://github.com/opendocument-app/compare-html
11
+ Project-URL: download, https://pypi.org/project/pyodr/#files
12
+ Project-URL: tracker, https://github.com/opendocument-app/compare-html/issues
13
+ Project-URL: release notes, https://github.com/opendocument-app/compare-html/releases
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ Dynamic: author-email
17
+ Dynamic: home-page
18
+ Dynamic: requires-python
19
+
20
+ # htmlcmp
21
+
22
+ Tool to compare (generated) HTML files visually and automatically using Selenium.
23
+
24
+ Provides various entry points to run:
25
+ - `compare-html` is a CLI tool to compare two directory structures containing HTML files
26
+ - `compare-html-server` starts a webserver and allows to inspect differences manually
27
+ - `html-render-diff` renders two HTML files and produces images
28
+ - `html-tidy` allows to run HTML tidy on a directory
29
+
30
+ Used for regression testing in https://github.com/opendocument-app/OpenDocument.core.
31
+
32
+ ## Install via PyPI
33
+
34
+ ```bash
35
+ pip install htmlcmp
36
+ ```
37
+
38
+ ## Download and run the docker image
39
+
40
+ ```bash
41
+ docker pull ghcr.io/opendocument-app/odr_core_test
42
+ ```
43
+
44
+ ```bash
45
+ docker run -ti \
46
+ -v $(pwd):/repo \
47
+ -p 8000:8000 \
48
+ ghcr.io/opendocument-app/odr_core_test \
49
+ compare-html-server /repo/REFERENCE /repo/MONITORED --compare --driver firefox --port 8000
50
+ ```
51
+
52
+ ## Manually build the docker image
53
+
54
+ ```bash
55
+ docker build --tag odr_core_test test/docker
56
+ ```
htmlcmp-1.0.1/PKG-INFO DELETED
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: htmlcmp
3
- Version: 1.0.1
4
- Summary: Compare HTML files by rendered output
5
- Home-page: https://github.com/opendocument-app/compare-html
6
- Author: Andreas Stefl
7
- Author-email: stefl.andreas@gmail.com
8
- Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
9
- Project-URL: homepage, https://opendocument.app/
10
- Project-URL: source, https://github.com/opendocument-app/compare-html
11
- Project-URL: download, https://pypi.org/project/pyodr/#files
12
- Project-URL: tracker, https://github.com/opendocument-app/compare-html/issues
13
- Project-URL: release notes, https://github.com/opendocument-app/compare-html/releases
14
- Requires-Python: >=3.7
15
- Description-Content-Type: text/markdown
16
- Dynamic: author-email
17
- Dynamic: home-page
18
- Dynamic: requires-python
19
-
20
- # comare-html
21
-
22
- originally moved out of https://github.com/opendocument-app/OpenDocument.core
23
-
24
- ## Manually build the docker image
25
-
26
- ```bash
27
- docker build --tag odr_core_test test/docker
28
- ```
htmlcmp-1.0.1/README.md DELETED
@@ -1,9 +0,0 @@
1
- # comare-html
2
-
3
- originally moved out of https://github.com/opendocument-app/OpenDocument.core
4
-
5
- ## Manually build the docker image
6
-
7
- ```bash
8
- docker build --tag odr_core_test test/docker
9
- ```
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- import os
5
- import sys
6
- import argparse
7
- import json
8
- import subprocess
9
- import shlex
10
- from common import bcolors
11
-
12
-
13
- def tidy_json(path):
14
- try:
15
- with open(path, "r") as f:
16
- json.load(f)
17
- return 0
18
- except ValueError:
19
- return 1
20
-
21
-
22
- def tidy_html(path):
23
- config_path = os.path.join(
24
- os.path.dirname(os.path.realpath(__file__)), ".html-tidy"
25
- )
26
- cmd = shlex.split(f'tidy -config "{config_path}" -q "{path}"')
27
- result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
28
- if result.returncode == 1:
29
- return 1
30
- if result.returncode > 1:
31
- return 2
32
- return 0
33
-
34
-
35
- def tidy_file(path):
36
- if path.endswith(".json"):
37
- return tidy_json(path)
38
- elif path.endswith(".html"):
39
- return tidy_html(path)
40
-
41
-
42
- def tidyable_file(path):
43
- if path.endswith(".json"):
44
- return True
45
- if path.endswith(".html"):
46
- return True
47
- return False
48
-
49
-
50
- def tidy_dir(path, level=0, prefix=""):
51
- prefix_file = prefix + "├── "
52
- if level == 0:
53
- print(f"tidy dir {path}")
54
-
55
- result = {
56
- "warning": [],
57
- "error": [],
58
- }
59
-
60
- items = [os.path.join(path, name) for name in os.listdir(path)]
61
- files = sorted(
62
- [path for path in items if os.path.isfile(path) and tidyable_file(path)]
63
- )
64
- dirs = sorted([path for path in items if os.path.isdir(path)])
65
-
66
- for filename in [os.path.basename(path) for path in files]:
67
- filepath = os.path.join(path, filename)
68
- tidy = tidy_file(filepath)
69
- if tidy == 0:
70
- print(f"{prefix_file}{bcolors.OKGREEN}{filename} ✓{bcolors.ENDC}")
71
- elif tidy == 1:
72
- print(f"{prefix_file}{bcolors.WARNING}{filename} ✓{bcolors.ENDC}")
73
- result["warning"].append(filepath)
74
- elif tidy > 1:
75
- print(f"{prefix_file}{bcolors.FAIL}{filename} ✘{bcolors.ENDC}")
76
- result["error"].append(filepath)
77
-
78
- for dirname in [os.path.basename(path) for path in dirs]:
79
- print(prefix + "├── " + dirname)
80
- subresult = tidy_dir(
81
- os.path.join(path, dirname), level=level + 1, prefix=prefix + "│ "
82
- )
83
- result["warning"].extend(subresult["warning"])
84
- result["error"].extend(subresult["error"])
85
-
86
- return result
87
-
88
-
89
- def main():
90
- parser = argparse.ArgumentParser()
91
- parser.add_argument("a")
92
- args = parser.parse_args()
93
-
94
- result = tidy_dir(args.a)
95
- if result["error"]:
96
- return 1
97
-
98
- return 0
99
-
100
-
101
- if __name__ == "__main__":
102
- sys.exit(main())
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: htmlcmp
3
- Version: 1.0.1
4
- Summary: Compare HTML files by rendered output
5
- Home-page: https://github.com/opendocument-app/compare-html
6
- Author: Andreas Stefl
7
- Author-email: stefl.andreas@gmail.com
8
- Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
9
- Project-URL: homepage, https://opendocument.app/
10
- Project-URL: source, https://github.com/opendocument-app/compare-html
11
- Project-URL: download, https://pypi.org/project/pyodr/#files
12
- Project-URL: tracker, https://github.com/opendocument-app/compare-html/issues
13
- Project-URL: release notes, https://github.com/opendocument-app/compare-html/releases
14
- Requires-Python: >=3.7
15
- Description-Content-Type: text/markdown
16
- Dynamic: author-email
17
- Dynamic: home-page
18
- Dynamic: requires-python
19
-
20
- # comare-html
21
-
22
- originally moved out of https://github.com/opendocument-app/OpenDocument.core
23
-
24
- ## Manually build the docker image
25
-
26
- ```bash
27
- docker build --tag odr_core_test test/docker
28
- ```
File without changes
File without changes
File without changes