generated from hjess/PythonTemplateProject
[main] Prod Creds
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 2m8s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 2m8s
This commit is contained in:
Binary file not shown.
BIN
__pycache__/markdown_render.cpython-311.pyc
Normal file
BIN
__pycache__/markdown_render.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/main.cpython-311.pyc
Normal file
BIN
app/__pycache__/main.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/controllers/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/controllers/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/controllers/__pycache__/category_controller.cpython-311.pyc
Normal file
BIN
app/controllers/__pycache__/category_controller.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/controllers/__pycache__/dynamic_controller.cpython-311.pyc
Normal file
BIN
app/controllers/__pycache__/dynamic_controller.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/services/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/services/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/services/__pycache__/markdown_processor.cpython-311.pyc
Normal file
BIN
app/services/__pycache__/markdown_processor.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/services/__pycache__/markdown_render.cpython-311.pyc
Normal file
BIN
app/services/__pycache__/markdown_render.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/services/__pycache__/metadata_processor.cpython-311.pyc
Normal file
BIN
app/services/__pycache__/metadata_processor.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,13 @@
|
|||||||
|
import json
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from amadeus import Client, ResponseError
|
from amadeus import Client, ResponseError
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import json
|
from flight_types import *
|
||||||
|
|
||||||
|
|
||||||
class FlightFilter:
|
class FlightFilter:
|
||||||
def __init__(self, api_key, api_secret):
|
def __init__(self, api_key, api_secret):
|
||||||
self.amadeus = Client(client_id=api_key, client_secret=api_secret)
|
self.amadeus = Client(client_id=api_key, client_secret=api_secret, hostname="production")
|
||||||
|
|
||||||
def get_flight_offers(self, request_body):
|
def get_flight_offers(self, request_body):
|
||||||
"""
|
"""
|
||||||
@@ -119,8 +119,12 @@ class FlightFilter:
|
|||||||
|
|
||||||
# Usage example
|
# Usage example
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
api_key = "uxDqIh36xPAUvpXnXynwAnH86pGBdIch"
|
#api_key = "uxDqIh36xPAUvpXnXynwAnH86pGBdIch"
|
||||||
api_secret = "xTSLooNZpJWantb5"
|
#api_secret = "xTSLooNZpJWantb5"
|
||||||
|
|
||||||
|
# PROD PROD PROD PROD PROD PROD PROD PROD PROD PROD
|
||||||
|
api_key = "ABRGQv6U7IWAYxwwmjqAOPUDGvuFMSjw"
|
||||||
|
api_secret = "BcwpSKf3FICJIxaw"
|
||||||
|
|
||||||
flight_filter = FlightFilter(api_key, api_secret)
|
flight_filter = FlightFilter(api_key, api_secret)
|
||||||
|
|
||||||
@@ -153,25 +157,57 @@ if __name__ == "__main__":
|
|||||||
"sources": ["GDS"],
|
"sources": ["GDS"],
|
||||||
"searchCriteria": {
|
"searchCriteria": {
|
||||||
"excludeAllotments": True,
|
"excludeAllotments": True,
|
||||||
"addOneWayOffers": False,
|
"addOneWayOffers": True,
|
||||||
"maxFlightOffers": 10,
|
"maxFlightOffers": 50,
|
||||||
"allowAlternativeFareOptions": True,
|
"allowAlternativeFareOptions": True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fetch flights
|
# Fetch flights
|
||||||
flights = flight_filter.get_flight_offers(request_body)
|
flights = flight_filter.get_flight_offers(request_body)
|
||||||
print(f"Raw flights data: {flights}")
|
with open("json_data.json", "w") as file:
|
||||||
|
json.dump(flights, file)
|
||||||
|
#
|
||||||
|
#DEBUG
|
||||||
|
#with open("json_data.json", "r") as file:
|
||||||
|
# flights = json.load(file)
|
||||||
|
|
||||||
|
#print(f"Raw flights data: {flights}")
|
||||||
|
|
||||||
|
real_flights = []
|
||||||
|
|
||||||
|
for flight in flights:
|
||||||
|
for x,v in flight.items():
|
||||||
|
if type(v) == list and "itineraries" in str(x).lower():
|
||||||
|
for flt, flt2 in flight.items():
|
||||||
|
if flt == "itineraries":
|
||||||
|
for itm in flt2:
|
||||||
|
for seg in itm.get("segments"):
|
||||||
|
departure = seg.get("departure").get("iataCode")
|
||||||
|
arrival = seg.get("arrival").get("iataCode")
|
||||||
|
print(f"{departure} -> {arrival}")
|
||||||
|
if (departure, arrival) in (("OPO", "CPH"), ("CPH", "OPO")):
|
||||||
|
print( f"{departure} -> {arrival}" )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Filter flights from OPO to CPH around 07:00 ± 1 hour
|
# Filter flights from OPO to CPH around 07:00 ± 1 hour
|
||||||
opo_to_cph_flights = flight_filter.filter_flights_by_time(
|
#opo_to_cph_flights = flight_filter.filter_flights_by_time(
|
||||||
flights, origin_filter="OPO", destination_filter="CPH", filter_time_str="06:00", hours=2
|
# flights, origin_filter="OPO", destination_filter="CPH", filter_time_str="06:00", hours=2
|
||||||
)
|
#)
|
||||||
|
|
||||||
# Filter flights from CPH to OPO around 18:30 ± 1 hour
|
# Filter flights from CPH to OPO around 18:30 ± 1 hour
|
||||||
cph_to_opo_flights = flight_filter.filter_flights_by_time(
|
#cph_to_opo_flights = flight_filter.filter_flights_by_time(
|
||||||
flights, origin_filter="CPH", destination_filter="OPO", filter_time_str="20:30", hours=2
|
# flights, origin_filter="CPH", destination_filter="OPO", filter_time_str="20:30", hours=2
|
||||||
)
|
#)
|
||||||
|
|
||||||
# Save to Excel
|
# Save to Excel
|
||||||
flight_filter.save_to_excel(opo_to_cph_flights, cph_to_opo_flights, "Filtered_Flights_OPO_CPH.xlsx")
|
#flight_filter.save_to_excel(opo_to_cph_flights, cph_to_opo_flights, "Filtered_Flights_OPO_CPH.xlsx")
|
||||||
|
|||||||
45
inspiration/TingSomSkalTilføjes/flight_types.py
Normal file
45
inspiration/TingSomSkalTilføjes/flight_types.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
|
||||||
|
# OopCompanion:suppressRename
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class AmenityProvider:
|
||||||
|
name: str
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Amenity:
|
||||||
|
description: str
|
||||||
|
isChargeable: bool
|
||||||
|
amenityType: str
|
||||||
|
amenityProvider: AmenityProvider
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class IncludedCheckedBags:
|
||||||
|
quantity: int
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class FareDetailsBySegment:
|
||||||
|
segmentId: str
|
||||||
|
cabin: str
|
||||||
|
fareBasis: str
|
||||||
|
brandedFare: str
|
||||||
|
brandedFareLabel: str
|
||||||
|
class_: str # 'class' is a reserved keyword in Python; use 'class_' instead
|
||||||
|
includedCheckedBags: IncludedCheckedBags
|
||||||
|
amenities: List[Amenity]
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Price:
|
||||||
|
currency: str
|
||||||
|
total: str
|
||||||
|
base: str
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Traveler:
|
||||||
|
travelerId: str
|
||||||
|
fareOption: str
|
||||||
|
travelerType: str
|
||||||
|
price: Price
|
||||||
|
fareDetailsBySegment: List[FareDetailsBySegment]
|
||||||
1
inspiration/TingSomSkalTilføjes/json_data.json
Normal file
1
inspiration/TingSomSkalTilføjes/json_data.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
1
inspiration/rnh_tax_calculator
Submodule
1
inspiration/rnh_tax_calculator
Submodule
Submodule inspiration/rnh_tax_calculator added at 7877b98884
@@ -1,3 +1,4 @@
|
|||||||
|
amadeus==11.0.0
|
||||||
annotated-types==0.7.0
|
annotated-types==0.7.0
|
||||||
anyio==4.7.0
|
anyio==4.7.0
|
||||||
beautifulsoup4==4.12.3
|
beautifulsoup4==4.12.3
|
||||||
@@ -12,15 +13,21 @@ markdown-it-py==3.0.0
|
|||||||
MarkupSafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
mistune==3.0.2
|
mistune==3.0.2
|
||||||
|
numpy==2.2.1
|
||||||
|
pandas==2.2.3
|
||||||
pillow==11.0.0
|
pillow==11.0.0
|
||||||
pydantic==2.10.3
|
pydantic==2.10.3
|
||||||
pydantic_core==2.27.1
|
pydantic_core==2.27.1
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
|
pytz==2024.2
|
||||||
PyYAML==6.0.2
|
PyYAML==6.0.2
|
||||||
|
six==1.17.0
|
||||||
sniffio==1.3.1
|
sniffio==1.3.1
|
||||||
soupsieve==2.6
|
soupsieve==2.6
|
||||||
starlette==0.41.3
|
starlette==0.41.3
|
||||||
typing_extensions==4.12.2
|
typing_extensions==4.12.2
|
||||||
|
tzdata==2024.2
|
||||||
uvicorn==0.32.1
|
uvicorn==0.32.1
|
||||||
uvloop==0.21.0
|
uvloop==0.21.0
|
||||||
watchfiles==1.0.0
|
watchfiles==1.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user