Inprogress refactor trying f-strings as template language

This commit is contained in:
Joe Rickerby
2020-04-25 16:09:11 +01:00
parent 0224d72931
commit 4f75eaabcd
4 changed files with 91 additions and 13 deletions
+18
View File
@@ -0,0 +1,18 @@
import os
import io
from typing import List, Tuple
class TemplateProject:
files: List[Tuple[str, str]]
def __init__(self, files):
self.files = files
def generate(self, path):
for filename, content in self.files:
file_path = os.path.join(path, filename)
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with io.open(file_path, 'w', encoding='utf8') as f:
f.write(content)