From 40f30842115407c2c319aab3890465abd217843e Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 10 Oct 2023 22:23:01 +0200 Subject: [PATCH] Improve calorie counter formatting. --- calories.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/calories.py b/calories.py index 5f71087..048aacc 100644 --- a/calories.py +++ b/calories.py @@ -10,12 +10,10 @@ def build_page(eatable_rows, consumption_rows, eatables_selection, day_rows): return """ """ + f"""
@@ -29,7 +27,7 @@ td, th { - + @@ -45,9 +43,9 @@ td, th { - - - + + + @@ -280,9 +278,9 @@ class MyServer(BaseHTTPRequestHandler): eatables += ""\ ""\ ""\ - ""\ - ""\ - ""\ + ""\ + ""\ + ""\ ""\ ""\ "" % (k, v.title, v.cals, v.sugar_g, v.standard_g, v.comments, k) @@ -293,26 +291,26 @@ class MyServer(BaseHTTPRequestHandler): consumptions += ""\ ""\ "%s"\ - ""\ + ""\ ""\ - "%.1f"\ - "%.1f"\ + "%.1f"\ + "%.1f"\ "" % (c.eatable_key, db.eatables[c.eatable_key].title, c.unit_count, r["cals"], r["sugar"]) day_rows = "" for date in sorted(db.days.keys()): day = db.days[date] day_rows = ""\ "%s"\ - "%.1f"\ - "%.1f"\ + "%.1f"\ + "%.1f"\ "" % (date, date[:10], day.calories, day.calories, day.sugar_g, day.sugar_g) + day_rows day_rows = ""\ "today:archive?"\ ""\ ""\ ""\ - "%.1f"\ - "%.1f"\ + "%.1f"\ + "%.1f"\ ""\ "" % (db.today_date, db.today.calories, db.today.calories, db.today.sugar_g, db.today.sugar_g) + day_rows page = build_page(eatables, consumptions, db.eatables_selection(), day_rows) -- 2.30.2