mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 21:23:02 +00:00
fix template for json (#87)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user