mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 04:49:00 +00:00
fix json detected as bin for #277
This commit is contained in:
@@ -149,12 +149,11 @@ class Templategen:
|
|||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
filetype = magic.from_file(src, mime=True)
|
filetype = magic.from_file(src, mime=True)
|
||||||
istext = filetype.startswith('text')
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_, filetype = utils.run(['file', '-b', src],
|
_, filetype = utils.run(['file', '-b', src],
|
||||||
raw=False, debug=self.debug)
|
raw=False, debug=self.debug)
|
||||||
filetype = filetype.strip()
|
filetype = filetype.strip()
|
||||||
istext = self._is_text(filetype)
|
istext = self._is_text(filetype)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('filetype \"{}\": {}'.format(src, filetype))
|
self.log.dbg('filetype \"{}\": {}'.format(src, filetype))
|
||||||
if self.debug:
|
if self.debug:
|
||||||
@@ -166,7 +165,7 @@ class Templategen:
|
|||||||
def _is_text(self, fileoutput):
|
def _is_text(self, fileoutput):
|
||||||
"""return if `file -b` output is ascii text"""
|
"""return if `file -b` output is ascii text"""
|
||||||
out = fileoutput.lower()
|
out = fileoutput.lower()
|
||||||
if 'text' in out:
|
if out.startswith('text'):
|
||||||
return True
|
return True
|
||||||
if 'empty' in out:
|
if 'empty' in out:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user