1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 20:54:51 +00:00

better identify templates

This commit is contained in:
deadc0de6
2018-09-01 19:00:54 +02:00
parent 89198eddb6
commit 0065595237
2 changed files with 11 additions and 4 deletions

View File

@@ -91,6 +91,13 @@ class Templategen:
data = f.read()
return data.decode('utf-8', 'replace')
def get_marker():
"""return identifier for template dotfile"""
return BLOCK_START
def is_template(path):
if not os.path.exists(path):
return False
with open(path, 'r') as f:
data = f.read()
markers = [BLOCK_START, VAR_START, COMMENT_START]
for marker in markers:
if marker in data:
return True
return False

View File

@@ -76,7 +76,7 @@ class Updater:
return self._handle_file(left, right)
def _is_template(self, path):
if Templategen.get_marker() not in open(path, 'r').read():
if not Templategen.is_template(path):
return False
self.log.warn('{} uses template, update manually'.format(path))
return True