Permalink
Browse files

Be more tolerant with binary files

  • Loading branch information...
1 parent f8cb42d commit 0e0129d8d8f3f72c14435c72417e1c1c45649864 @jiqingtang committed Oct 7, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 xd.py
View
9 xd.py
@@ -92,11 +92,14 @@ def check(real, short):
return shortest[0]
def isText(lines):
- null_trans = string.maketrans('', '')
+ total = 0
+ binary = 0
for line in lines:
- if line.translate(null_trans, string.printable):
+ total += len(line)
+ binary += len(line.translate(None, string.printable))
+ if total >= 1024 and binary * 100 >= total:
return False
- return True
+ return total == 0 or binary * 100 < total
#------------------------------ scm ------------------------------

0 comments on commit 0e0129d

Please sign in to comment.