[diffoscope] 06/06: Rename html_output to compute_visual_diffs and explain its purpose.
Maria Glukhova
siamezzze-guest at moszumanska.debian.org
Sat Apr 29 19:16:59 CEST 2017
This is an automated email from the git hooks/post-receive script.
siamezzze-guest pushed a commit to branch siamezzze/image-visual-comparison
in repository diffoscope.
commit 0b7c8f3b33ae07092b39a0fa63f3841165cfbf87
Author: Maria Glukhova <siamezzze at gmail.com>
Date: Sat Apr 29 02:29:23 2017 +0300
Rename html_output to compute_visual_diffs and explain its purpose.
---
diffoscope/comparators/gif.py | 2 +-
diffoscope/comparators/image.py | 4 ++--
diffoscope/comparators/png.py | 2 +-
diffoscope/config.py | 2 +-
diffoscope/main.py | 7 +++++--
tests/comparators/test_gif.py | 4 ++--
tests/comparators/test_ico_image.py | 2 +-
tests/comparators/test_jpeg_image.py | 2 +-
tests/comparators/test_png.py | 2 +-
9 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/diffoscope/comparators/gif.py b/diffoscope/comparators/gif.py
index d29bd43..a1f65c0 100644
--- a/diffoscope/comparators/gif.py
+++ b/diffoscope/comparators/gif.py
@@ -72,7 +72,7 @@ class GifFile(File):
source='gifbuild',
)
differences = [gifbuild_diff]
- if gifbuild_diff is not None and Config().html_output and \
+ if gifbuild_diff is not None and Config().compute_visual_diffs and \
can_compose_gif_images(self, other):
try:
logger.debug(
diff --git a/diffoscope/comparators/image.py b/diffoscope/comparators/image.py
index f6e36ef..30e3e47 100644
--- a/diffoscope/comparators/image.py
+++ b/diffoscope/comparators/image.py
@@ -131,7 +131,7 @@ class JPEGImageFile(File):
other.path,
source="Image content",
)
- if content_diff is not None and Config().html_output and \
+ if content_diff is not None and Config().compute_visual_diffs and \
same_size(self, other):
try:
logger.debug(
@@ -173,7 +173,7 @@ class ICOImageFile(File):
png_b,
source="Image content",
)
- if content_diff is not None and Config().html_output and \
+ if content_diff is not None and Config().compute_visual_diffs and \
same_size(self, other):
if get_image_size(self.path) == get_image_size(other.path):
logger.debug(
diff --git a/diffoscope/comparators/png.py b/diffoscope/comparators/png.py
index 521fbb0..0e7d17b 100644
--- a/diffoscope/comparators/png.py
+++ b/diffoscope/comparators/png.py
@@ -50,7 +50,7 @@ class PngFile(File):
def compare_details(self, other, source=None):
sng_diff = Difference.from_command(Sng, self.path, other.path, source='sng')
differences = [sng_diff]
- if sng_diff is not None and Config().html_output and \
+ if sng_diff is not None and Config().compute_visual_diffs and \
same_size(self, other):
try:
logger.debug(
diff --git a/diffoscope/config.py b/diffoscope/config.py
index 7962683..6a9eff5 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -34,7 +34,7 @@ class Config(object):
fuzzy_threshold = 60
enforce_constraints = True
excludes = ()
- html_output = False
+ compute_visual_diffs = False
_singleton = {}
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 186bfb0..9a89db1 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -285,8 +285,11 @@ def run_diffoscope(parsed_args):
Config().fuzzy_threshold = parsed_args.fuzzy_threshold
Config().new_file = parsed_args.new_file
Config().excludes = parsed_args.excludes
- Config().html_output = any((parsed_args.html_output,
- parsed_args.html_output_directory))
+ # Don't waste time computing visual differences if we won't use them.
+ Config().compute_visual_diffs = any((
+ parsed_args.html_output,
+ parsed_args.html_output_directory,
+ ))
set_path()
set_locale()
logger.debug('Starting comparison')
diff --git a/tests/comparators/test_gif.py b/tests/comparators/test_gif.py
index bb898c7..f714f64 100644
--- a/tests/comparators/test_gif.py
+++ b/tests/comparators/test_gif.py
@@ -54,7 +54,7 @@ def test_compare_non_existing(monkeypatch, gif1):
@skip_unless_tools_exist('gifbuild', 'compose', 'convert', 'identify')
def test_has_visuals(monkeypatch, gif3, gif4):
- monkeypatch.setattr(Config(), 'html_output', True)
+ monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
gif_diff = gif3.compare(gif4)
assert len(gif_diff.details) == 2
assert len(gif_diff.details[1].visuals) == 2
@@ -63,7 +63,7 @@ def test_has_visuals(monkeypatch, gif3, gif4):
@skip_unless_tools_exist('gifbuild', 'compose', 'convert', 'identify')
def test_no_visuals_different_size(monkeypatch, gif1, gif2):
- monkeypatch.setattr(Config(), 'html_output', True)
+ monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
gif_diff = gif1.compare(gif2)
assert len(gif_diff.details) == 1
assert len(gif_diff.details[0].visuals) == 0
diff --git a/tests/comparators/test_ico_image.py b/tests/comparators/test_ico_image.py
index aa1eddb..dbea9e3 100644
--- a/tests/comparators/test_ico_image.py
+++ b/tests/comparators/test_ico_image.py
@@ -60,7 +60,7 @@ def test_diff_meta(differences_meta):
@skip_unless_tools_exist('img2txt', 'compose', 'convert', 'identify')
def test_has_visuals(monkeypatch, image1, image2):
- monkeypatch.setattr(Config(), 'html_output', True)
+ monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
ico_diff = image1.compare(image2)
assert len(ico_diff.details) == 2
assert len(ico_diff.details[0].visuals) == 2
diff --git a/tests/comparators/test_jpeg_image.py b/tests/comparators/test_jpeg_image.py
index 8dd7e5d..78735db 100644
--- a/tests/comparators/test_jpeg_image.py
+++ b/tests/comparators/test_jpeg_image.py
@@ -76,7 +76,7 @@ def test_diff_meta(differences_meta):
@skip_unless_tools_exist('img2txt', 'compose', 'convert', 'identify')
def test_has_visuals(monkeypatch, image1, image2):
- monkeypatch.setattr(Config(), 'html_output', True)
+ monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
jpg_diff = image1.compare(image2)
assert len(jpg_diff.details) == 2
assert len(jpg_diff.details[0].visuals) == 2
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index 76378b7..7740f11 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -52,7 +52,7 @@ def test_compare_non_existing(monkeypatch, png1):
@skip_unless_tools_exist('sng', 'compose', 'convert', 'identify')
def test_has_visuals(monkeypatch, png1, png2):
- monkeypatch.setattr(Config(), 'html_output', True)
+ monkeypatch.setattr(Config(), 'compute_visual_diffs', True)
png_diff = png1.compare(png2)
assert len(png_diff.details) == 2
assert len(png_diff.details[1].visuals) == 2
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list