From a4fa4df920e176fb71cbc5e7b123f2e004702d41 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 17 Feb 2019 19:24:30 +0100 Subject: [PATCH] fix template for json (#87) --- dotdrop/templategen.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index 9c0474d..ae49f47 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -77,13 +77,24 @@ class Templategen: filetype = filetype.strip() if self.debug: self.log.dbg('\"{}\" filetype: {}'.format(src, filetype)) - istext = 'text' in filetype or 'empty' in filetype + istext = self._is_text(filetype) if self.debug: self.log.dbg('\"{}\" is text: {}'.format(src, istext)) if not istext: return self._handle_bin_file(src) return self._handle_text_file(src) + def _is_text(self, fileoutput): + """return if `file -b` output is ascii text""" + out = fileoutput.lower() + if 'text' in out: + return True + if 'empty' in out: + return True + if 'json' in out: + return True + return False + def _handle_text_file(self, src): """write text to file""" template_rel_path = os.path.relpath(src, self.base)