File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1649,11 +1649,11 @@ def getFileType(filePath):
16491649 """
16501650
16511651 try :
1652- _ = magic .from_file (filePath )
1652+ desc = magic .from_file (filePath ) or ""
16531653 except :
16541654 return "unknown"
16551655
1656- return "text" if "ASCII" in _ or "text" in _ else "binary"
1656+ return "text" if any ( _ in desc . lower () for _ in ( "ascii" , "text" )) else "binary"
16571657
16581658def getCharset (charsetType = None ):
16591659 """
@@ -1669,14 +1669,14 @@ def getCharset(charsetType=None):
16691669 if charsetType is None :
16701670 asciiTbl .extend (xrange (0 , 128 ))
16711671
1672- # 0 or 1
1672+ # Binary
16731673 elif charsetType == CHARSET_TYPE .BINARY :
16741674 asciiTbl .extend ([0 , 1 ])
16751675 asciiTbl .extend (xrange (47 , 50 ))
16761676
16771677 # Digits
16781678 elif charsetType == CHARSET_TYPE .DIGITS :
1679- asciiTbl .extend ([0 , 1 ])
1679+ asciiTbl .extend ([0 , 9 ])
16801680 asciiTbl .extend (xrange (47 , 58 ))
16811681
16821682 # Hexadecimal
You can’t perform that action at this time.
0 commit comments