mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 03:14:15 +00:00
properly handle binary when checking for template #58
This commit is contained in:
@@ -114,8 +114,12 @@ class Templategen:
|
|||||||
"""test if file pointed by path is a template"""
|
"""test if file pointed by path is a template"""
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
return False
|
return False
|
||||||
with open(path, 'r') as f:
|
try:
|
||||||
data = f.read()
|
with open(path, 'r') as f:
|
||||||
|
data = f.read()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# is binary so surely no template
|
||||||
|
return False
|
||||||
markers = [BLOCK_START, VAR_START, COMMENT_START]
|
markers = [BLOCK_START, VAR_START, COMMENT_START]
|
||||||
for marker in markers:
|
for marker in markers:
|
||||||
if marker in data:
|
if marker in data:
|
||||||
|
|||||||
Reference in New Issue
Block a user