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

Unified Diff: tools/resources/optimize-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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/resources/ico_tools.py ('k') | ui/resources/resource_check/ico_files.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resources/optimize-ico-files.py
diff --git a/tools/resources/optimize-ico-files.py b/tools/resources/optimize-ico-files.py
index 2635e9c509ba5cf6c3cec048e97c584b9670de8e..5f0f7163990df71cb812516f44a4ccad76a92d51 100755
--- a/tools/resources/optimize-ico-files.py
+++ b/tools/resources/optimize-ico-files.py
@@ -32,6 +32,9 @@ def main(args=None):
nargs='+', help='.ico files to be crushed')
parser.add_argument('-o', dest='optimization_level', metavar='OPT', type=int,
help='optimization level')
+ parser.add_argument('--lint', dest='lint', action='store_true',
+ help='test the ICO file without modifying (set status '
+ 'to 1 on error)')
parser.add_argument('-d', '--debug', dest='debug', action='store_true',
help='enable debug logging')
@@ -40,11 +43,20 @@ def main(args=None):
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)
+ failed = False
for file in args.files:
buf = StringIO.StringIO()
file.seek(0, os.SEEK_END)
old_length = file.tell()
file.seek(0, os.SEEK_SET)
+
+ if args.lint:
+ for error in ico_tools.LintIcoFile(file):
+ logging.warning('%s: %s', file.name, error)
+ # Any errors should cause this process to exit with a status of 1.
+ failed = True
+ continue
+
ico_tools.OptimizeIcoFile(file, buf, args.optimization_level)
new_length = len(buf.getvalue())
@@ -63,5 +75,7 @@ def main(args=None):
logging.info('%s : %d => %d (%d bytes : %d %%)', file.name, old_length,
new_length, saving, int(saving_percent * 100))
+ return failed
+
if __name__ == '__main__':
sys.exit(main())
« no previous file with comments | « tools/resources/ico_tools.py ('k') | ui/resources/resource_check/ico_files.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698