# HG changeset patch # User Thierry Florac # Date 1549355905 -3600 # Node ID d49bcf3821872af253e51e70c6a1d8c23a87ee21 # Parent a68e640a408929d2fdfb321e21fbd4a6e929d791 Added equality method to compare two geometries diff -r a68e640a4089 -r d49bcf382187 src/pyams_file/image.py --- a/src/pyams_file/image.py Tue Feb 05 09:37:43 2019 +0100 +++ b/src/pyams_file/image.py Tue Feb 05 09:38:25 2019 +0100 @@ -19,11 +19,10 @@ from zope.interface import implementer from zope.schema.fieldproperty import FieldProperty +from pyams_file import _ from pyams_file.interfaces import IImage, IResponsiveImage, IThumbnailGeometry, IThumbnailer, IThumbnails from pyams_utils.adapter import ContextAdapter, adapter_config -from pyams_file import _ - WEB_FORMATS = ('JPEG', 'PNG', 'GIF') THUMB_SIZE = re.compile('^(?:\w+\:)?([0-9]+)x([0-9]+)$') @@ -41,6 +40,15 @@ def __repr__(self): return ''.format(self) + def __eq__(self, other): + if IThumbnailGeometry.providedBy(other): + return (self.x1 == other.x1) and \ + (self.x2 == other.x2) and \ + (self.y1 == other.y1) and \ + (self.y2 == other.y2) + else: + return False + @adapter_config(context=IImage, provides=IThumbnailer) class ImageThumbnailer(ContextAdapter):