diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 12:46:38 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 12:46:38 +0000 |
commit | f0a51fb571f46531025fa09240bbc3e1af925e84 (patch) | |
tree | 558b4f0e737fda4b9ab60f252c9c23b8a4ca523e /tools/site_compare/operators | |
parent | 6390be368205705f49ead3cec40396519f13b889 (diff) | |
download | chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.zip chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.gz chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.bz2 |
Fixes CRLF and trailing white spaces.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/site_compare/operators')
-rw-r--r-- | tools/site_compare/operators/__init__.py | 10 | ||||
-rw-r--r-- | tools/site_compare/operators/equals.py | 16 | ||||
-rw-r--r-- | tools/site_compare/operators/equals_with_mask.py | 26 |
3 files changed, 26 insertions, 26 deletions
diff --git a/tools/site_compare/operators/__init__.py b/tools/site_compare/operators/__init__.py index 02eac07..f60e8e8 100644 --- a/tools/site_compare/operators/__init__.py +++ b/tools/site_compare/operators/__init__.py @@ -9,18 +9,18 @@ __author__ = 'jhaas@google.com (Jonathan Haas)' def GetOperator(operator): """Given an operator by name, returns its module. - + Args: operator: string describing the comparison - + Returns: module """ - + # TODO(jhaas): come up with a happy way of integrating multiple operators # with different, possibly divergent and possibly convergent, operators. - + module = __import__(operator, globals(), locals(), ['']) - + return module diff --git a/tools/site_compare/operators/equals.py b/tools/site_compare/operators/equals.py index c7654e9..4054fa6 100644 --- a/tools/site_compare/operators/equals.py +++ b/tools/site_compare/operators/equals.py @@ -11,31 +11,31 @@ from PIL import ImageChops def Compare(file1, file2, **kwargs): """Compares two images to see if they're identical. - + Args: file1: path to first image to compare file2: path to second image to compare kwargs: unused for this operator - + Returns: None if the images are identical A tuple of (errorstring, image) if they're not """ kwargs = kwargs # unused parameter - + im1 = Image.open(file1) im2 = Image.open(file2) - + if im1.size != im2.size: return ("The images are of different size (%s vs %s)" % (im1.size, im2.size), im1) diff = ImageChops.difference(im1, im2) - + if max(diff.getextrema()) != (0, 0): return ("The images differ", diff) else: return None - - - + + + diff --git a/tools/site_compare/operators/equals_with_mask.py b/tools/site_compare/operators/equals_with_mask.py index fd4000b..d6abd53 100644 --- a/tools/site_compare/operators/equals_with_mask.py +++ b/tools/site_compare/operators/equals_with_mask.py @@ -13,49 +13,49 @@ import os.path def Compare(file1, file2, **kwargs): """Compares two images to see if they're identical subject to a mask. - + An optional directory containing masks is supplied. If a mask exists which matches file1's name, areas under the mask where it's black are ignored. - + Args: file1: path to first image to compare file2: path to second image to compare kwargs: ["maskdir"] contains the directory holding the masks - + Returns: None if the images are identical A tuple of (errorstring, image) if they're not """ - + maskdir = None if "maskdir" in kwargs: maskdir = kwargs["maskdir"] - + im1 = Image.open(file1) im2 = Image.open(file2) - + if im1.size != im2.size: return ("The images are of different size (%r vs %r)" % (im1.size, im2.size), im1) diff = ImageChops.difference(im1, im2) - + if maskdir: maskfile = os.path.join(maskdir, os.path.basename(file1)) if os.path.exists(maskfile): mask = Image.open(maskfile) - + if mask.size != im1.size: return ("The mask is of a different size than the images (%r vs %r)" % (mask.size, im1.size), mask) - + diff = ImageChops.multiply(diff, mask.convert(diff.mode)) - + if max(diff.getextrema()) != (0, 0): return ("The images differ", diff) else: return None - - - + + + |