def CheckFileIsValid(self, size, mime, width, height): if self._min_size is not None and size < self._min_size: raise HydrusExceptions.FileSizeException( 'File was ' + HydrusData.ToHumanBytes(size) + ' but the lower limit is ' + HydrusData.ToHumanBytes(self._min_size) + '.') if self._max_size is not None and size > self._max_size: raise HydrusExceptions.FileSizeException( 'File was ' + HydrusData.ToHumanBytes(size) + ' but the upper limit is ' + HydrusData.ToHumanBytes(self._max_size) + '.') if mime == HC.IMAGE_GIF and self._max_gif_size is not None and size > self._max_gif_size: raise HydrusExceptions.FileSizeException( 'File was ' + HydrusData.ToHumanBytes(size) + ' but the upper limit for gifs is ' + HydrusData.ToHumanBytes(self._max_gif_size) + '.') if self._min_resolution is not None: (min_width, min_height) = self._min_resolution too_thin = width is not None and width < min_width too_short = height is not None and height < min_height if too_thin or too_short: raise HydrusExceptions.FileSizeException( 'File had resolution ' + HydrusData.ConvertResolutionToPrettyString((width, height)) + ' but the lower limit is ' + HydrusData.ConvertResolutionToPrettyString( self._min_resolution)) if self._max_resolution is not None: (max_width, max_height) = self._max_resolution too_wide = width is not None and width > max_width too_tall = height is not None and height > max_height if too_wide or too_tall: raise HydrusExceptions.FileSizeException( 'File had resolution ' + HydrusData.ConvertResolutionToPrettyString((width, height)) + ' but the upper limit is ' + HydrusData.ConvertResolutionToPrettyString( self._max_resolution))