1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 14:31:46 +00:00

fix json detected as bin for #277

This commit is contained in:
deadc0de6
2020-11-06 15:18:26 +01:00
parent 962ed2d9d2
commit 2c1041307d

View File

@@ -149,12 +149,11 @@ class Templategen:
try:
import magic
filetype = magic.from_file(src, mime=True)
istext = filetype.startswith('text')
except ImportError:
_, filetype = utils.run(['file', '-b', src],
raw=False, debug=self.debug)
filetype = filetype.strip()
istext = self._is_text(filetype)
istext = self._is_text(filetype)
if self.debug:
self.log.dbg('filetype \"{}\": {}'.format(src, filetype))
if self.debug:
@@ -166,7 +165,7 @@ class Templategen:
def _is_text(self, fileoutput):
"""return if `file -b` output is ascii text"""
out = fileoutput.lower()
if 'text' in out:
if out.startswith('text'):
return True
if 'empty' in out:
return True