Commit 8b7aacba authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers 🐦

generate copies non-template files to out directory

parent 941c1283
Pipeline #1291 failed with stages
in 43 seconds
......@@ -5,10 +5,26 @@ import shutil
from j2static import build
def find_all(dirpath):
files = []
for path in dirpath.iterdir():
if path.is_file():
files.append(path)
else:
files.extend( find_all(path) )
return files
def generate(args, outdir='site/'):
out_path = pathlib.Path(outdir)
template_path = pathlib.Path(args.template_dir)
generator = build.get_builder("html", args.template_dir)
for template in generator.get_files():
out_file = out_path / template
generator.generate(template, out_file)
for path in find_all(template_path):
relative_path = path.relative_to(template_path)
out_file = out_path / relative_path
if generator.filter(path):
generator.generate(str(relative_path), out_file)
elif path.is_file() and relative_path.name[0] != '_':
out_file.parent.mkdir(exist_ok=True, parents=True)
shutil.copy(path, out_file)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment