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