aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorAlex Schofield <git@ajschof.me>2026-04-27 09:37:15 +0100
committerAlex Schofield <git@ajschof.me>2026-04-27 09:37:15 +0100
commit79e8f8e76fd18a45a7f513b952261cc7d1a4fee9 (patch)
treec490d19262a8decd11415ada4838fcbcf7f5f1d9 /main.py
parentd787c2d720c1cd732ca7efcece93588504eab3a6 (diff)
downloadfuelnearme-79e8f8e76fd18a45a7f513b952261cc7d1a4fee9.tar.gz
fuelnearme-79e8f8e76fd18a45a7f513b952261cc7d1a4fee9.zip
improve sort function to handle N/A fuel prices
Diffstat (limited to 'main.py')
-rw-r--r--main.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.py b/main.py
index f092eeb..ae842f4 100644
--- a/main.py
+++ b/main.py
@@ -67,13 +67,16 @@ def filter_df(dframe, arguments, loc):
"e10_price": round(e10_price / 100, 2),
"diesel_price": round(diesel_price / 100, 2),
}
- near_stations.append(station_dict)
+ na_dict = {
+ k: (v if v != 0.00 else "N/A") for (k, v) in station_dict.items()
+ }
+ near_stations.append(na_dict)
return near_stations
def sort_stations(stations: list[dict], sort: str) -> list[dict]:
sort_key = SORT_KV.get(sort)
- return sorted(stations, key=lambda d: d[sort_key])
+ return sorted(stations, key=lambda d: d[sort_key] if d[sort_key] != "N/A" else 999)
def output_stations(stations):
git.ajschof.me — hosted by ajschofield — powered by cgit