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

Unified Diff: presubmit_canned_checks.py

Issue 149096: Fix CheckSvnProperty canned check. (Closed)
Patch Set: Created 11 years, 6 months 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 | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 3aaecf86b18d306205ba581cf9b9f552c274d1a3..b0c6087809d0d8bf83f3570eb1839c878f58890e 100755
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -198,21 +198,23 @@ def CheckSvnForCommonMimeTypes(input_api, output_api):
"""Checks that common binary file types have the correct svn:mime-type."""
output = []
files = input_api.AffectedFiles(include_deletes=False)
+ def IsExts(x, exts):
+ path = x.LocalPath()
+ for extension in exts:
+ if path.endswith(extension):
+ return True
+ return False
def FilterFiles(extension):
- return filter(lambda x: x.endswith(extension), files)
- def JpegFiles():
- return filter(lambda x: (x.endswith('.jpg') or x.endswith('.jpeg') or
- x.endswith('.jpe')),
- files)
+ return filter(lambda x: IsExts(x, extension), files)
def RunCheck(mime_type, files):
output.extend(CheckSvnProperty(input_api, output_api, 'svn:mime-type',
mime_type, files))
- RunCheck('application/pdf', FilterFiles('.pdf'))
- RunCheck('image/bmp', FilterFiles('.bmp'))
- RunCheck('image/gif', FilterFiles('.gif'))
- RunCheck('image/png', FilterFiles('.png'))
- RunCheck('image/jpeg', JpegFiles())
- RunCheck('image/vnd.microsoft.icon', FilterFiles('.ico'))
+ RunCheck('application/pdf', FilterFiles(['.pdf']))
+ RunCheck('image/bmp', FilterFiles(['.bmp']))
+ RunCheck('image/gif', FilterFiles(['.gif']))
+ RunCheck('image/png', FilterFiles(['.png']))
+ RunCheck('image/jpeg', FilterFiles(['.jpg', '.jpeg', '.jpe']))
+ RunCheck('image/vnd.microsoft.icon', FilterFiles(['.ico']))
return output
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698