| 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. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 """Supports checking WebKit style in png files.""" | 24 """Supports checking WebKit style in png files.""" |
| 25 | 25 |
| 26 from webkitpy.common import read_checksum_from_png | 26 from webkitpy.common import read_checksum_from_png |
| 27 from webkitpy.common.system.system_host import SystemHost | 27 from webkitpy.common.system.system_host import SystemHost |
| 28 | 28 |
| 29 | 29 |
| 30 class PNGChecker(object): | 30 class PNGChecker(object): |
| 31 """Check svn:mime-type for checking style""" | |
| 32 | 31 |
| 33 categories = set(['image/png']) | 32 categories = set(['image/png']) |
| 34 | 33 |
| 35 def __init__(self, file_path, handle_style_error, host=None): | 34 def __init__(self, file_path, handle_style_error, host=None): |
| 36 self._file_path = file_path | 35 self._file_path = file_path |
| 37 self._handle_style_error = handle_style_error | 36 self._handle_style_error = handle_style_error |
| 38 self._host = host or SystemHost() | 37 self._host = host or SystemHost() |
| 39 self._fs = self._host.filesystem | 38 self._fs = self._host.filesystem |
| 40 | 39 |
| 41 def check(self, inline=None): | 40 def check(self, inline=None): |
| 42 if self._fs.exists(self._file_path) and self._file_path.endswith('-expec
ted.png'): | 41 if self._fs.exists(self._file_path) and self._file_path.endswith('-expec
ted.png'): |
| 43 with self._fs.open_binary_file_for_reading(self._file_path) as fileh
andle: | 42 with self._fs.open_binary_file_for_reading(self._file_path) as fileh
andle: |
| 44 if not read_checksum_from_png.read_checksum(filehandle): | 43 if not read_checksum_from_png.read_checksum(filehandle): |
| 45 self._handle_style_error( | 44 self._handle_style_error( |
| 46 0, 'image/png', 5, | 45 0, 'image/png', 5, |
| 47 'Image lacks a checksum. Generate pngs using run-webkit-
tests to ensure they have a checksum.') | 46 'Image lacks a checksum. Generate pngs using run-webkit-
tests to ensure they have a checksum.') |
| OLD | NEW |