Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: ui/resources/resource_check/ico_files.py

Issue 1372113003: Add a PRESUBMIT check for broken .ico files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@optimize-ico-files-modularize
Patch Set: Update copyright year. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/resources/optimize-ico-files.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Presubmit script for Chromium browser resources.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools, and see
9 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here.
11 """
12
13 import os
14 import sys
15
16 class IcoFiles(object):
17 """Verifier of ICO files for Chromium resources.
18 """
19
20 def __init__(self, input_api, output_api):
21 """ Initializes IcoFiles with path."""
22 self.input_api = input_api
23 self.output_api = output_api
24
25 tool_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
26 '../../../tools/resources')
27 sys.path.insert(0, tool_path)
28
29 def RunChecks(self):
30 """Verifies the correctness of the ICO files.
31
32 Returns:
33 An array of presubmit errors if any ICO files were broken in some way.
34 """
35 results = []
36 affected_files = self.input_api.AffectedFiles(include_deletes=False)
37 for f in affected_files:
38 path = f.LocalPath()
39 if os.path.splitext(path)[1].lower() != '.ico':
40 continue
41
42 # Import this module from here (to avoid importing it in the highly common
43 # case where there are no ICO files being changed).
44 import ico_tools
45
46 repository_path = self.input_api.change.RepositoryRoot()
47
48 with open(os.path.join(repository_path, path), 'rb') as ico_file:
49 errors = list(ico_tools.LintIcoFile(ico_file))
50 if errors:
51 error_string = '\n'.join(' * ' + e for e in errors)
52 results.append(self.output_api.PresubmitError(
53 '%s: This file does not meet the standards for Chromium ICO '
54 'files.\n%s\n Please run '
55 'tools/resources/optimize-ico-files.py on this file. See '
56 'chrome/app/theme/README for details.' % (path, error_string)))
57 return results
OLDNEW
« no previous file with comments | « tools/resources/optimize-ico-files.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698