1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 16:49:17 +00:00

mime type for file -b

This commit is contained in:
deadc0de6
2020-11-07 14:40:42 +01:00
parent 045ca11930
commit 68b901e667

View File

@@ -149,9 +149,13 @@ class Templategen:
try: try:
import magic import magic
filetype = magic.from_file(src, mime=True) filetype = magic.from_file(src, mime=True)
if self.debug:
self.log.dbg('using \"magic\" for filetype identification')
except ImportError: except ImportError:
_, filetype = utils.run(['file', '-b', src], _, filetype = utils.run(['file', '-b', '--mime-type', src],
raw=False, debug=self.debug) raw=False, debug=self.debug)
if self.debug:
self.log.dbg('using \"file\" for filetype identification')
filetype = filetype.strip() filetype = filetype.strip()
istext = self._is_text(filetype) istext = self._is_text(filetype)
if self.debug: if self.debug:
@@ -167,8 +171,6 @@ class Templategen:
out = fileoutput.lower() out = fileoutput.lower()
if out.startswith('text'): if out.startswith('text'):
return True return True
if 'text' in out:
return True
if 'empty' in out: if 'empty' in out:
return True return True
if 'json' in out: if 'json' in out: