return res.text, 1
-def bottle_template():
+def today_tomorrow_template(template: str) -> str:
today = datetime.now()
tomorrow = today + timedelta(days=1)
- return f"BM 4 floz\nexp {today.strftime('%b %d')}\nuse {tomorrow.strftime('%b %d')}"
-
-
-def puree_template():
- tomorrow = datetime.now() + timedelta(days=1)
- return f"\nPurée\nuse {tomorrow.strftime('%b %d')}"
-
-
-def cracker_template():
- tomorrow = datetime.now() + timedelta(days=1)
- return f"Graham\nCracker\nuse {tomorrow.strftime('%b %d')}"
+ return template.format(
+ today=today.strftime("%b %d"), tomorrow=tomorrow.strftime("%b %d")
+ )
templates = {
- "bottle": {"label": "Bottle", "function": bottle_template},
- "rayleigh": {"label": "Rayleigh", "value": "Rayleigh\nArmstrong-Dodgen"},
- "kepler": {"label": "Kepler", "value": "Kepler\nArmstrong-Dodgen"},
- "puree": {"label": "Purée", "function": puree_template},
- "cracker": {"label": "Cracker", "function": cracker_template},
+ "bottle": {
+ "label": "Bottle",
+ "function": today_tomorrow_template,
+ "template": "BM 5 floz\nexp {today}\nuse {tomorrow}",
+ },
+ "rayleigh": {"label": "Rayleigh", "value": "Rayleigh\nArmstrong-\nDodgen"},
+ "kepler": {"label": "Kepler", "value": "Kepler\nArmstrong-\nDodgen"},
+ "puree": {
+ "label": "Purée",
+ "function": today_tomorrow_template,
+ "template": "\nPurée\nuse {tomorrow}",
+ },
+ "cracker": {
+ "label": "Cracker",
+ "function": today_tomorrow_template,
+ "template": "Graham\nCracker\nuse {tomorrow}",
+ },
+ "strawberries": {
+ "label": "Strawberries",
+ "function": today_tomorrow_template,
+ "template": "Sliced\nStrawberries\nuse {tomorrow}",
+ },
+ "cheese": {
+ "label": "Cheese",
+ "function": today_tomorrow_template,
+ "template": "Cheese\nSticks\nuse {tomorrow}",
+ },
+ "carrots": {
+ "label": "Carrots",
+ "function": today_tomorrow_template,
+ "template": "Cooked\nCarrots\nuse {tomorrow}",
+ },
+ "sunbutter": {
+ "label": "Sunbutter",
+ "function": today_tomorrow_template,
+ "template": "Sunbutter\nJelly\nuse {tomorrow}",
+ },
+ "pasta": {
+ "label": "Pasta",
+ "function": today_tomorrow_template,
+ "template": "Pasta\n\nuse {tomorrow}",
+ },
}
for name, template in templates.items():
if "value" in template:
return template["value"]
if "function" in template:
- return template["function"]()
+ template_args = {
+ key: template[key]
+ for key in template
+ if key not in {"function", "name", "value", "label"}
+ }
+ return template["function"](**template_args)
return "No template defined"