| OLD | NEW |
| 1 # Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged | 1 # Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright |
| 9 # notice, this list of conditions and the following disclaimer in the | 9 # notice, this list of conditions and the following disclaimer in the |
| 10 # documentation and/or other materials provided with the distribution. | 10 # documentation and/or other materials provided with the distribution. |
| 11 # | 11 # |
| 12 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 12 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 13 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 13 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 14 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 14 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 15 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 15 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 16 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 16 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 17 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 17 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 18 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 18 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 19 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 19 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 20 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | 23 |
| 24 | 24 |
| 25 """Supports checking WebKit style in png files.""" | 25 """Supports checking WebKit style in png files.""" |
| 26 | 26 |
| 27 import os | |
| 28 import re | |
| 29 | 27 |
| 30 from webkitpy.common import read_checksum_from_png | 28 from webkitpy.common import read_checksum_from_png |
| 31 from webkitpy.common.system.systemhost import SystemHost | 29 from webkitpy.common.system.systemhost import SystemHost |
| 32 from webkitpy.common.checkout.scm.detection import SCMDetector | 30 from webkitpy.common.checkout.scm.detection import SCMDetector |
| 33 | 31 |
| 34 | 32 |
| 35 class PNGChecker(object): | 33 class PNGChecker(object): |
| 36 """Check svn:mime-type for checking style""" | 34 """Check svn:mime-type for checking style""" |
| 37 | 35 |
| 38 categories = set(['image/png']) | 36 categories = set(['image/png']) |
| 39 | 37 |
| 40 def __init__(self, file_path, handle_style_error, host=None): | 38 def __init__(self, file_path, handle_style_error, host=None): |
| 41 self._file_path = file_path | 39 self._file_path = file_path |
| 42 self._handle_style_error = handle_style_error | 40 self._handle_style_error = handle_style_error |
| 43 self._host = host or SystemHost() | 41 self._host = host or SystemHost() |
| 44 self._fs = self._host.filesystem | 42 self._fs = self._host.filesystem |
| 45 | 43 |
| 46 def check(self, inline=None): | 44 def check(self, inline=None): |
| 47 errorstr = "" | 45 errorstr = "" |
| 48 config_file_path = "" | 46 config_file_path = "" |
| 49 | 47 |
| 50 if self._fs.exists(self._file_path) and self._file_path.endswith("-expec
ted.png"): | 48 if self._fs.exists(self._file_path) and self._file_path.endswith("-expec
ted.png"): |
| 51 with self._fs.open_binary_file_for_reading(self._file_path) as fileh
andle: | 49 with self._fs.open_binary_file_for_reading(self._file_path) as fileh
andle: |
| 52 if not read_checksum_from_png.read_checksum(filehandle): | 50 if not read_checksum_from_png.read_checksum(filehandle): |
| 53 self._handle_style_error( | 51 self._handle_style_error( |
| 54 0, 'image/png', 5, "Image lacks a checksum. Generate png
s using run-webkit-tests to ensure they have a checksum.") | 52 0, 'image/png', 5, "Image lacks a checksum. Generate png
s using run-webkit-tests to ensure they have a checksum.") |
| OLD | NEW |