from os import path, listdir, system
from jinja2 import Environment, FileSystemLoader
from datetime import datetime
+from tqdm import tqdm
class RecipeBook:
def __init__(self):
def render_html(self):
keywords = {}
- for recipe in self.recipes:
+ print("Generating HTML pages...")
+ for recipe in tqdm(self.recipes):
recipe.render_html(self.html_environment)
for word in recipe.recipe["information"]["keywords"]:
recipe.recipe["information"]["description"]
)]}
+ print("Generating homepage...")
template = self.html_environment.get_template("index.html")
with open("index.html", "w") as f:
f.write(template.render(recipes = self.recipes, keywords = keywords, time = datetime.now()))
def render_latex(self):
- for recipe in self.recipes:
+ print("Generating pdf documents...")
+ for recipe in tqdm(self.recipes):
recipe.render_latex(self.latex_environment)
class Recipe:
with open(path.join("build", self.recipe["tex"]), "w") as f:
f.write(template.render(recipe = self.recipe))
- system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/{self.recipe['tex']}'")
+ system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/{self.recipe['tex']}' > /dev/zero")
system(f"mv build/{self.recipe['pdf']} recipes")
# main
recipe_book = RecipeBook()
recipe_book.render_html()
recipe_book.render_latex()
+print("Happy baking!")