mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 09:14:16 +00:00
use magic for determining file types and remove mkdir dependency
This commit is contained in:
@@ -146,12 +146,17 @@ class Templategen:
|
||||
|
||||
def _handle_file(self, src):
|
||||
"""generate the file content from template"""
|
||||
_, filetype = utils.run(['file', '-b', src],
|
||||
raw=False, debug=self.debug)
|
||||
filetype = filetype.strip()
|
||||
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)
|
||||
if self.debug:
|
||||
self.log.dbg('filetype \"{}\": {}'.format(src, filetype))
|
||||
istext = self._is_text(filetype)
|
||||
if self.debug:
|
||||
self.log.dbg('is text \"{}\": {}'.format(src, istext))
|
||||
if not istext:
|
||||
|
||||
Reference in New Issue
Block a user