示例#1
0
from flight_data import FlightData
from flight_search import FlightSearch
from notification_manager import NotificationManager
from datetime import datetime, timedelta

data_manager = DataManager()
flight_search = FlightSearch()
sheet_data = data_manager.get_destination_data()
notification_manager = NotificationManager()

ORIGIN_CITY_IATA = "LON"

if sheet_data[0]["iataCode"] == "":
    flight_search = FlightSearch()
    for row in sheet_data:
        row["iataCode"] = flight_search.get_destination_code(row["city"])

    data_manager.destination_data = sheet_data
    data_manager.update_destination_codes()

today = datetime.now()
tomorrow = (today + timedelta(days=1)).strftime("%d/%m/%Y")
six_months = (today + timedelta(days=180)).strftime("%d/%m/%Y")

for destination in sheet_data:
    flight = flight_search.get_flight_prices(ORIGIN_CITY_IATA,
                                             destination["iataCode"],
                                             from_date=tomorrow,
                                             to_date=six_months)

    if flight is not None and flight.price < destination["lowestPrice"]:
示例#2
0
    'lowestPrice': 378
}]

data_manager = DataManager()
#sheet_data = data_manager.get_sheet_data()
flight_search = FlightSearch()
notification_manager = NotificationManager()

ORIGIN_CITY_IATA = "LON"

# if I use row and when index
for row in sheet_data:
    if row["iataCode"] == '':
        print("still being called")
        iataCode = flight_search.get_destination_code(
            row['city']
        )  # TODO: 5. when to use instance and when to create a new object and update
        row["iataCode"] = iataCode
        data_manager.put_sheet_data(row)

print(sheet_data)
# TODO: 6. why objects are so mutable, how and when the objects will mutate, and in which case it will not change

tomorrow = datetime.now() + timedelta(days=1)
six_month_from_today = datetime.now() + timedelta(days=(6 * 30))

for destination in sheet_data:
    print(destination)
    flight = flight_search.check_flights(ORIGIN_CITY_IATA,
                                         destination["iataCode"],
                                         from_time=tomorrow,