Simplify code

This commit is contained in:
Edward Betts 2024-04-17 14:48:18 +01:00
parent 32e07d4ce4
commit 0fcaf76104
3 changed files with 11 additions and 17 deletions

View file

@ -2,7 +2,6 @@
"""Web page to show upcoming events."""
import decimal
import inspect
import operator
import os.path
@ -126,12 +125,6 @@ def travel_list() -> str:
if all("distance" in leg for leg in train["legs"]):
train["distance"] = sum(leg["distance"] for leg in train["legs"])
for travel_type in flights, trains:
for item in travel_type:
price = item.get("price")
if price:
item["price"] = decimal.Decimal(price)
return flask.render_template("travel.html", flights=flights, trains=trains)
@ -187,10 +180,6 @@ def accommodation_list() -> str:
"""Page showing a list of past, present and future accommodation."""
data_dir = app.config["PERSONAL_DATA"]
items = travel.parse_yaml("accommodation", data_dir)
for item in items:
price = item.get("price")
if price:
item["price"] = decimal.Decimal(price)
stays_in_2024 = [item for item in items if item["from"].year == 2024]
total_nights_2024 = sum(