From a37a9bbb440e6361313f97efa6def897d5e39b13 Mon Sep 17 00:00:00 2001 From: Max Value Date: Sun, 18 Jan 2026 00:02:51 +0000 Subject: [PATCH] Built recipe helper --- Makefile | 3 + helper.py | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.gmi | 70 +++++++++++--------- index.html | 111 +++++++++++++++++-------------- 4 files changed, 294 insertions(+), 79 deletions(-) create mode 100644 helper.py diff --git a/Makefile b/Makefile index 8b0573a..758b474 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ all : .venv/touchfile -mkdir recipes .venv/bin/python sous.py +helper : .venv/touchfile + .venv/bin/python helper.py + .venv/touchfile : requirements.txt python3 -m venv .venv .venv/bin/python -m pip install -r requirements.txt diff --git a/helper.py b/helper.py new file mode 100644 index 0000000..369a1d5 --- /dev/null +++ b/helper.py @@ -0,0 +1,189 @@ +HELP = """ +(c) Will Greenwood 2025 + +For converting over bread recipies with different and volumetric units. + +You are asked to give the ingredients of the recipe line by line, and from this +the bakers percentage will be calculated. There are some additional commands: + + "reset" - clears the history + "generate" - generates the toml code for the recipe page + "help" - prints this help text + +The syntax for an ingredient is the following: + + of + +- The number may be a decimal +- The unit should always be plural if not in shorthand ("pounds" not "pound") +- the ingredient should be formatted as in the toml, with no spaces +- "base" includes the ingredient as the 100% that makes up the flour usually + +It can the following units: + + g, grams + kg, kilograms + l, litres + lb, pounds + oz, ounces + tsp, teaspoons + tbsp, tablespoons + cups + pints + gallons + quarts + large-eggs + eggs, medium-eggs + small-eggs + +And the following materials + + wholemeal-flour + white-flour + rye-flour + water + yeast + milk + sugar + butter + salt + yougurt + egg +""" + +# CONSTANTS + +VOLUMETRIC = { # this converts the units into ml of water + "tsp": 4.929, + "teaspoons": 4.929, + "tbsp": 14.79, + "tablespoons": 14.79, + "cups": 236.6, + "pints": 473.2, + "gallons": 3785, + "quarts": 946.4 + } + +WEIGHTED = { + "g": 1, + "grams": 1, + "kg": 1000, + "kilograms": 1000, + "l": 1000, + "litres": 1000, + "lb": 453.6, + "pounds": 453.6, + "oz": 28.35, + "ounces": 28.35, + "large-eggs": 68, + "medium-eggs": 58, + "eggs": 58, + "small-eggs": 50 + } + +INGREDIENTS = { # this converts ml to g (fallback is 1:1) + "water": 1, + "milk": 1.035, + "wholemeal-flour": 0.478, + "flour": 0.55, + "white-flour": 0.55, + "rye-flour": 0.478, + "egg": 1.04, + "yeast": 0.95, + "yougurt": 1.06, + "salt": 1.201, + "potato": 0.769, + "butter": 0.959, + "olive-oil": 0.92, + "oil": 0.92, + "sugar": 0.849, + "brown-sugar": 0.823, + "syrup": 1.43, + "honey": 1.42, + "seeds": 0.62 + } + +ingredients = [] +base_ingredients = [] + +while True: + try: + line = input("ingredient > ") + except KeyboardInterrupt: + print("\nHappy baking!") + quit() + + # if the user has inputted a commands + if len(line.split()) == 1: + if line == "reset": # reset function + ingredients = [] + base_ingredients = [] + continue + + elif line == "help": # reset function + print(HELP) + continue + + elif line == "generate": # generate the recipe + if len(base_ingredients) == 0: + print(f"Cannot generate, no base ingredients") + continue + + base_total = sum([i["units"] for i in base_ingredients]) + + all_ingredients = base_ingredients + ingredients + for i in all_ingredients: + i["units"] = i["units"] * (100/base_total) + if i["units"] > 20: + i["units"] = round(i["units"]) + else: + i["units"] = round(i["units"], 2) + + all_ingredients.sort(key=lambda i: i["units"], reverse=True) + for i in all_ingredients: + print(f"{i['name']} = {i['units']}") + continue + + else: # if the command is not valid... + print(f"Incorrect syntax") + continue + + # if the user has entered a non-base ingredient: + if len(line.split()) == 4: + qty, measure, _, ingredient = line.split() + base = False + + # if the user has entered a base ingredient: + elif len(line.split()) == 5: + qty, measure, _, ingredient, base = line.split() + if base != "base": # check that this is not a mistake + print(f"Incorrect syntax '{base}'") + continue + base = True + + else: # if the user has made a mistake with the entry + print("Incorrect syntax") + continue + + if measure not in WEIGHTED and measure not in VOLUMETRIC: + # if the unit has been misspelled + print(f"No record for '{measure}' as a unit") + continue + + # calculate the g of water in this case and multiply by the density + if measure in WEIGHTED: + g = float(qty) * WEIGHTED[measure] + + if measure in VOLUMETRIC: + g = float(qty) * VOLUMETRIC[measure] + if ingredient in INGREDIENTS: + g *= INGREDIENTS[ingredient] + else: # if the ingredient is not recorded + print(f"'{ingredient}' not found, using 1 g <-> 1 ml") + + # add to the list + record = {"units": g, "name": ingredient} + if base: + base_ingredients.append(record) + else: + ingredients.append(record) diff --git a/index.gmi b/index.gmi index d69d37a..b107533 100644 --- a/index.gmi +++ b/index.gmi @@ -26,75 +26,78 @@ In many of these recipes, the salt measurement is a constant 1.5%. This is perso ### All recipes +=> recipes/calvel-imitation-panettone.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) => recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) => recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) -=> recipes/levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) => recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) -=> recipes/levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) => recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) => recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) -=> recipes/challah.gmi Challah (Jewish sweet-bread.) -=> recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> recipes/calvel-levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) +=> recipes/challah.gmi Challah (Polish sweet-bread.) +=> recipes/challah-polish.gmi Challah with pre-ferment (Polish sweet-bread with polish.) => recipes/calvel-polish.gmi Polish pre-ferment (Recommended polish recipe from 'Taste of Bread'.) => recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) => recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) -=> recipes/panettone-imitation.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) => recipes/panettone-v3.gmi Panettone v3 (Panettone.) => recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> recipes/floris-polish-rye.gmi Polish rye bread (Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery') +=> recipes/calvel-levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) => recipes/ciabatta.gmi Ciabatta (Light Italian bread.) ### Keywords -Sourdough - -=> recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) -=> recipes/levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) -=> recipes/levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) -=> recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) -=> recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) -=> recipes/panettone-imitation.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) -=> recipes/panettone-v3.gmi Panettone v3 (Panettone.) - White +=> recipes/calvel-imitation-panettone.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) => recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) => recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) => recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) -=> recipes/levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) => recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) => recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) -=> recipes/challah.gmi Challah (Jewish sweet-bread.) -=> recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> recipes/calvel-levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) +=> recipes/challah.gmi Challah (Polish sweet-bread.) +=> recipes/challah-polish.gmi Challah with pre-ferment (Polish sweet-bread with polish.) => recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) -=> recipes/panettone-imitation.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) => recipes/panettone-v3.gmi Panettone v3 (Panettone.) => recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) => recipes/ciabatta.gmi Ciabatta (Light Italian bread.) +Sourdough + +=> recipes/calvel-imitation-panettone.gmi Panettone Imitation (Imitation Panettone from 'Taste of Bread'.) +=> recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) +=> recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> recipes/calvel-levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) +=> recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) +=> recipes/panettone-v3.gmi Panettone v3 (Panettone.) +=> recipes/floris-polish-rye.gmi Polish rye bread (Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery') +=> recipes/calvel-levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) + Vegan => recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) => recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) -=> recipes/levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) -=> recipes/levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) => recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) => recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> recipes/calvel-levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) => recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) => recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> recipes/calvel-levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) => recipes/ciabatta.gmi Ciabatta (Light Italian bread.) Yeasted => recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) -=> recipes/levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) => recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) -=> recipes/levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) -=> recipes/challah.gmi Challah (Jewish sweet-bread.) -=> recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> recipes/calvel-levain-de-pate.gmi Levain De Pâte (Levain De Pate recipe from 'Taste of Bread'.) +=> recipes/challah.gmi Challah (Polish sweet-bread.) +=> recipes/challah-polish.gmi Challah with pre-ferment (Polish sweet-bread with polish.) => recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) => recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) => recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> recipes/floris-polish-rye.gmi Polish rye bread (Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery') +=> recipes/calvel-levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) => recipes/ciabatta.gmi Ciabatta (Light Italian bread.) Brioche @@ -102,21 +105,26 @@ Brioche => recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) => recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) -Wholemeal - -=> recipes/levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) - Pre-Ferment => recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) -=> recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> recipes/challah-polish.gmi Challah with pre-ferment (Polish sweet-bread with polish.) => recipes/calvel-polish.gmi Polish pre-ferment (Recommended polish recipe from 'Taste of Bread'.) => recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) Rye => recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) +=> recipes/floris-polish-rye.gmi Polish rye bread (Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery') + +Floris + +=> recipes/floris-polish-rye.gmi Polish rye bread (Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery') + +Wholemeal + +=> recipes/calvel-levain-de-pate-wholemeal.gmi Levain De Pâte (wholemeal) (Levain De Pâte ajusted for cheap chapatti flour. Under development.) -=> https://git.ozva.co.uk/?p=bread;a=commit;h=HEAD Last compiled at 2025-08-30 17:28:14.092317 \ No newline at end of file +=> https://git.ozva.co.uk/?p=bread;a=commit;h=HEAD Last compiled at 2026-01-17 22:37:14.182681 \ No newline at end of file diff --git a/index.html b/index.html index 9bf9cf5..e0d2b6e 100644 --- a/index.html +++ b/index.html @@ -25,23 +25,23 @@

All recipes

Keywords

-

Sourdough

+

White

-

White

+

Sourdough

@@ -117,18 +121,18 @@
  • Kaiser rolls (vegan) Under development.
  • -
  • Levain De Pâte (wholemeal) Levain De Pâte ajusted for cheap chapatti flour. Under development.
  • - -
  • Levain De Pâte Levain De Pate recipe from 'Taste of Bread'.
  • -
  • White yeasted with polish pre-ferment v4 Less acidic flavor than the v4 sourdough.
  • Sourdough white v4 Sourdough sandwich loaf, similar to french bread.
  • +
  • Levain De Pâte Levain De Pate recipe from 'Taste of Bread'.
  • +
  • Straight white yeasted v4 Regular white yeasted bread.
  • Ciabatta with pre-ferment Light Italian bread with polish.
  • +
  • Levain De Pâte (wholemeal) Levain De Pâte ajusted for cheap chapatti flour. Under development.
  • +
  • Ciabatta Light Italian bread.
  • @@ -138,15 +142,13 @@
  • Kaiser rolls (vegan) Under development.
  • -
  • Levain De Pâte (wholemeal) Levain De Pâte ajusted for cheap chapatti flour. Under development.
  • -
  • Kaiser rolls Chainbaker kaiser rolls.
  • -
  • Levain De Pâte Levain De Pate recipe from 'Taste of Bread'.
  • +
  • Levain De Pâte Levain De Pate recipe from 'Taste of Bread'.
  • -
  • Challah Jewish sweet-bread.
  • +
  • Challah Polish sweet-bread.
  • -
  • Challah with pre-ferment Jewish sweet-bread with polish.
  • +
  • Challah with pre-ferment Polish sweet-bread with polish.
  • Seeded Sourdough Rye Sourdough rye with seeds. Can be used as a guide for other seeded breads.
  • @@ -154,6 +156,10 @@
  • Ciabatta with pre-ferment Light Italian bread with polish.
  • +
  • Polish rye bread Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery'
  • + +
  • Levain De Pâte (wholemeal) Levain De Pâte ajusted for cheap chapatti flour. Under development.
  • +
  • Ciabatta Light Italian bread.
  • @@ -167,19 +173,12 @@ -

    Wholemeal

    - -

    Pre-Ferment

    + +

    Floris

    +
      + +
    • Polish rye bread Polish rye bread from Maria Floris' 'Bakery, cakes and simple confectionery'
    • + +
    + +

    Wholemeal

    + @@ -202,7 +217,7 @@
  • Add rye and other ancient grain breads
  • -

    Last compiled at 2025-08-30 17:28:14.109140

    +

    Last compiled at 2026-01-17 22:37:14.200446

    \ No newline at end of file -- 2.39.2