From 68b901e667e953515fdb2d92c7eab25fd49638e5 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sat, 7 Nov 2020 14:40:42 +0100 Subject: [PATCH] mime type for file -b --- dotdrop/templategen.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index 971dd61..d5a718c 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -149,9 +149,13 @@ class Templategen: try: import magic filetype = magic.from_file(src, mime=True) + if self.debug: + self.log.dbg('using \"magic\" for filetype identification') except ImportError: - _, filetype = utils.run(['file', '-b', src], + _, filetype = utils.run(['file', '-b', '--mime-type', src], raw=False, debug=self.debug) + if self.debug: + self.log.dbg('using \"file\" for filetype identification') filetype = filetype.strip() istext = self._is_text(filetype) if self.debug: @@ -167,8 +171,6 @@ class Templategen: out = fileoutput.lower() if out.startswith('text'): return True - if 'text' in out: - return True if 'empty' in out: return True if 'json' in out: