From 2c1041307d755453f0b13a9e69869d045bee18a8 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Fri, 6 Nov 2020 15:18:26 +0100 Subject: [PATCH] fix json detected as bin for #277 --- dotdrop/templategen.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index ae40617..e376462 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -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