mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-07 13:58:25 +00:00
fix template for json (#87)
This commit is contained in:
@@ -77,13 +77,24 @@ class Templategen:
|
|||||||
filetype = filetype.strip()
|
filetype = filetype.strip()
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('\"{}\" filetype: {}'.format(src, filetype))
|
self.log.dbg('\"{}\" filetype: {}'.format(src, filetype))
|
||||||
istext = 'text' in filetype or 'empty' in filetype
|
istext = self._is_text(filetype)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('\"{}\" is text: {}'.format(src, istext))
|
self.log.dbg('\"{}\" is text: {}'.format(src, istext))
|
||||||
if not istext:
|
if not istext:
|
||||||
return self._handle_bin_file(src)
|
return self._handle_bin_file(src)
|
||||||
return self._handle_text_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):
|
def _handle_text_file(self, src):
|
||||||
"""write text to file"""
|
"""write text to file"""
|
||||||
template_rel_path = os.path.relpath(src, self.base)
|
template_rel_path = os.path.relpath(src, self.base)
|
||||||
|
|||||||
Reference in New Issue
Block a user