summaryrefslogtreecommitdiff
path: root/chromium/ui/resources/resource_check/resource_scale_factors.py
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-11-21 14:09:57 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-11-29 15:14:36 +0100
commiteb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch)
tree2c7c940e1dbee81b89d935626110816b494aa32c /chromium/ui/resources/resource_check/resource_scale_factors.py
parent9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff)
downloadqtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/ui/resources/resource_check/resource_scale_factors.py')
-rw-r--r--chromium/ui/resources/resource_check/resource_scale_factors.py24
1 files changed, 3 insertions, 21 deletions
diff --git a/chromium/ui/resources/resource_check/resource_scale_factors.py b/chromium/ui/resources/resource_check/resource_scale_factors.py
index 9ddc70fda60..f974447ccf2 100644
--- a/chromium/ui/resources/resource_check/resource_scale_factors.py
+++ b/chromium/ui/resources/resource_check/resource_scale_factors.py
@@ -15,10 +15,6 @@ import os
import struct
-class InvalidPNGException(Exception):
- pass
-
-
class ResourceScaleFactors(object):
"""Verifier of image dimensions for Chromium resources.
@@ -48,8 +44,7 @@ class ResourceScaleFactors(object):
def ImageSize(filename):
with open(filename, 'rb', buffering=0) as f:
data = f.read(24)
- if data[:8] != '\x89PNG\r\n\x1A\n' or data[12:16] != 'IHDR':
- raise InvalidPNGException
+ assert data[:8] == '\x89PNG\r\n\x1A\n' and data[12:16] == 'IHDR'
return struct.unpack('>ii', data[16:24])
# Returns a list of valid scaled image sizes. The valid sizes are the
@@ -80,9 +75,6 @@ class ResourceScaleFactors(object):
if relative_path not in files:
files.append(relative_path)
- corrupt_png_error = ('Corrupt PNG in file %s. Note that binaries are not '
- 'correctly uploaded to the code review tool and must be directly '
- 'submitted using the dcommit command.')
for f in files:
base_image = self.input_api.os_path.join(self.paths[0][1], f)
if not os.path.exists(base_image):
@@ -90,12 +82,7 @@ class ResourceScaleFactors(object):
'Base image %s does not exist' % self.input_api.os_path.join(
repository_path, base_image)))
continue
- try:
- base_dimensions = ImageSize(base_image)
- except InvalidPNGException:
- results.append(self.output_api.PresubmitError(corrupt_png_error %
- self.input_api.os_path.join(repository_path, base_image)))
- continue
+ base_dimensions = ImageSize(base_image)
# Find all scaled versions of the base image and verify their sizes.
for i in range(1, len(self.paths)):
image_path = self.input_api.os_path.join(self.paths[i][1], f)
@@ -103,12 +90,7 @@ class ResourceScaleFactors(object):
continue
# Ensure that each image for a particular scale factor is the
# correct scale of the base image.
- try:
- scaled_dimensions = ImageSize(image_path)
- except InvalidPNGException:
- results.append(self.output_api.PresubmitError(corrupt_png_error %
- self.input_api.os_path.join(repository_path, image_path)))
- continue
+ scaled_dimensions = ImageSize(image_path)
for dimension_name, base_size, scaled_size in zip(
('width', 'height'), base_dimensions, scaled_dimensions):
valid_sizes = ValidSizes(base_size, self.paths[i][0])