mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 13:01:18 +00:00
better identify templates
This commit is contained in:
@@ -91,6 +91,13 @@ class Templategen:
|
|||||||
data = f.read()
|
data = f.read()
|
||||||
return data.decode('utf-8', 'replace')
|
return data.decode('utf-8', 'replace')
|
||||||
|
|
||||||
def get_marker():
|
def is_template(path):
|
||||||
"""return identifier for template dotfile"""
|
if not os.path.exists(path):
|
||||||
return BLOCK_START
|
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
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Updater:
|
|||||||
return self._handle_file(left, right)
|
return self._handle_file(left, right)
|
||||||
|
|
||||||
def _is_template(self, path):
|
def _is_template(self, path):
|
||||||
if Templategen.get_marker() not in open(path, 'r').read():
|
if not Templategen.is_template(path):
|
||||||
return False
|
return False
|
||||||
self.log.warn('{} uses template, update manually'.format(path))
|
self.log.warn('{} uses template, update manually'.format(path))
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user