def get_template_dir(self):
""" return the directory containing jinja2 templates
ex: web-p2 is web-p2/partners/templates
"""
template_dirs = set()
for root, subdir, files in os.walk(self.__target_dir):
for fname in files:
fpath = os.path.join(root, fname)
if fname.endswith(".html"):
with open(fpath, "rb") as f:
# Hmm, smells like a jinja template!
if b"{%" in f.read():
template_dirs.add(root)
# If there are multiple template directories in a repo we might need
# repo-specific overrides.
return None if not template_dirs else os.path.commonprefix(template_dirs)
评论列表
文章目录