Unify dprint

This commit is contained in:
Marty Oehme 2025-08-11 23:24:12 +02:00
parent 11233e544f
commit f14e28eeab
Signed by: Marty
GPG key ID: 4E535BC19C61886E

11
main.py
View file

@ -3,16 +3,17 @@ import json
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from pprint import pprint
from typing import Any from typing import Any
import requests import requests
BASE_URL = "https://www.nightjet.com" BASE_URL = "https://www.nightjet.com"
BASE_DIR = "out"
CSV_LOWEST_FILE = f"{BASE_DIR}/lowest.csv"
CSV_ALL_PRICES_SUFFIX = f"{BASE_DIR}/_all_prices.csv"
def dprint(txt) -> None: def dprint(txt) -> None:
return
print(txt) print(txt)
@ -178,10 +179,6 @@ def get_lowest_price(prices: list[Price]) -> Price:
return lowest return lowest
CSV_LOWEST_FILE = "lowest.csv"
CSV_ALL_PRICES_SUFFIX = "_all_prices.csv"
def dump_all_prices_to_csv(prices: list[Price]) -> None: def dump_all_prices_to_csv(prices: list[Price]) -> None:
with open(f"{int(datetime.now().timestamp())}{CSV_ALL_PRICES_SUFFIX}", "w") as f: with open(f"{int(datetime.now().timestamp())}{CSV_ALL_PRICES_SUFFIX}", "w") as f:
writer = csv.writer(f) writer = csv.writer(f)
@ -235,7 +232,7 @@ def main():
# if the price changed, add it to lowest prices # if the price changed, add it to lowest prices
if not previous or new.price != previous.price: if not previous or new.price != previous.price:
print(f"PRICE CHANGE. {previous} -> {new}") dprint(f"PRICE CHANGE. {previous} -> {new}")
notify_user(previous or Price("", "", 0.0), new, "alerta-alerta-pichi-133") notify_user(previous or Price("", "", 0.0), new, "alerta-alerta-pichi-133")
add_to_csv(new) add_to_csv(new)