changeset 9:1ba95b6130d4

Allow binary files to not end in newline.
author Sjoerd Mullender <sjoerd@acm.org>
date Fri, 06 Mar 2015 14:41:19 +0100 (2015-03-06)
parents 42b21d1a4e84
children bd1ca3d502d6
files check_whitespace.py
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/check_whitespace.py	Wed Nov 05 09:33:14 2014 +0100
+++ b/check_whitespace.py	Fri Mar 06 14:41:19 2015 +0100
@@ -17,6 +17,23 @@
 '''
 
 import re
+import os
+
+binary_suffixes = (
+    '.bam',
+    '.bmp',
+    '.bz2',
+    '.chm',
+    '.cpl',
+    '.dia',
+    '.dll',
+    '.gz',
+    '.ico',
+    '.pdf',
+    '.png',
+    '.rtf',
+    '.zip',
+)
 
 def trailing_whitespace(difflines):
     linenum = 0
@@ -61,7 +78,8 @@
             elif adding \
                  and not islink \
                  and line.startswith(r'\ No newline at end of file') \
-                 and not filename.endswith('vertoo.data'):
+                 and not filename.endswith('vertoo.data') \
+                 and not os.path.splitext(filename)[1] in binary_suffixes:
                 adding = False
                 yield filename, linenum, 'no newline at end of file'
             # hunk body - check for an added line with bad whitespace