1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-08 09:04:16 +00:00

recursively check for template files for #58

This commit is contained in:
deadc0de6
2018-09-24 13:22:20 +02:00
parent e018cde397
commit 44dc7affc6
2 changed files with 121 additions and 0 deletions

View File

@@ -92,6 +92,24 @@ class Templategen:
return data.decode('utf-8', 'replace')
def is_template(path):
"""recursively check if any file is a template within path"""
if os.path.isfile(path):
# is file
return Templategen._is_template(path)
for entry in os.listdir(path):
fpath = os.path.join(path, entry)
if not os.path.isfile(fpath):
# rec explore dir
if Templategen.is_template(fpath):
return True
else:
# is file a template
if Templategen._is_template(fpath):
return True
return False
def _is_template(path):
"""test if file pointed by path is a template"""
if not os.path.isfile(path):
return False
with open(path, 'r') as f: