pax_global_header00006660000000000000000000000064145031254630014515gustar00rootroot0000000000000052 comment=4e5098e1039945e2b48dd51cebd0f1f8f9ff875c ntilley905-faadelays-4e5098e/000077500000000000000000000000001450312546300157275ustar00rootroot00000000000000ntilley905-faadelays-4e5098e/.gitignore000066400000000000000000000040051450312546300177160ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ cover/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder .pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # pytype static type analyzer .pytype/ # Cython debug symbols cython_debug/ # VSCode .vscode/ntilley905-faadelays-4e5098e/LICENSE000066400000000000000000000020551450312546300167360ustar00rootroot00000000000000MIT License Copyright (c) 2020 Nathan Tilley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.ntilley905-faadelays-4e5098e/README.md000066400000000000000000000035451450312546300172150ustar00rootroot00000000000000# FAA Airport Status This is a simple Python package used to retrieve data from the FAA's NAS Status API. ## Classes The following classes are available and in some cases dynamically generated when retrieving data: Class | Information Provided | Methods --- | --- | --- ArriveDepartDelay | Airport, Status, Minimum delay, Maximum delay, Trend, Reason, Update time GroundDelay | Airport, Status, Average delay, Maximum delay, Start time, End time, Reason, Update time, URL to the advisory, Departure scope (if applicable), Included Facilities (if applicable), Included flights (if applicable) GroundStop | Airport, Status, End Time, Reason, Update time, URL to advisory, Included facilities (if applicable), Included flights (if applicable), Probabibility of extension Closure | Airport, Status, Begin Time, End Time, Update time, NOTAM text AirportConfig | Airport, Time the data was created, Arrival runway config, Departure runway config, Arrival rate, Source time stamp Airport | Code (provide when creating, IATA format), *Name*, *Longitude*, *Latitude*, Bool of if airport is deicing (see note), Bool of any delays, Count of delays, GroundDelay object, GroundStop object, Depart Delay object (ArriveDepartDelay), Arrive Delay object (ArriveDepartDelay), Closure object, Airport config | Update Items in *italics* are not updated until delay data is present Note: Information about airport deicing is untested ## Methods Available `get_airport_delays(airport_code, session)` requires the code for the airport to get delays for in IATA format (i.e. ATL for Atlanta) and an asyncio HTTP session (such as aiohttp.ClientSession) and returns an Airport object ## Support [![Buy me a coffee][buymeacoffee-shield]][buymeacoffee] [buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg [buymeacoffee]: https://www.buymeacoffee.com/ntilley905 ntilley905-faadelays-4e5098e/faadelays/000077500000000000000000000000001450312546300176605ustar00rootroot00000000000000ntilley905-faadelays-4e5098e/faadelays/__init__.py000066400000000000000000000227751450312546300220060ustar00rootroot00000000000000"""Fetch latest data from the FAA ASWS API.""" from aiohttp import ClientSession, ClientResponseError BASE_URL = "https://nasstatus.faa.gov/api/airport-events" class ArriveDepartDelay: # Class for Arrival/Departure delays def __init__(self, airport, status=False, minimum=None, maximum=None, average_delay=None, trend=None, reason=None, update_time=None): self.airport = airport self.status = status self.minimum = minimum self.maximum = maximum self.average_delay = average_delay self.trend = trend self.reason = reason self.update_time = update_time class GroundDelay: # Class for Ground Delays def __init__(self, airport, status=False, average=None, max_delay=None, start_time=None, end_time=None, reason=None, update_time=None, advisory_url=None, departure_scope=None, included_facilities=None, included_flights=None): self.airport = airport self.status = status self.average = average self.max_delay = max_delay self.start_time = start_time self.end_time = end_time self.reason = reason self.update_time = update_time self.advisory_url = advisory_url self.departure_scope = departure_scope self.included_facilities = included_facilities self.included_flights = included_flights class GroundStop: # Class for Ground Stops def __init__(self, airport, status=False, endtime=None, reason=None, update_time=None, advisory_url=None, included_facilities=None, included_flights=None, probability_of_extension=None): self.airport = airport self.status = status self.endtime = endtime self.reason = reason self.update_time = update_time self.advisory_url = advisory_url self.included_facilities = included_facilities self.included_flights = included_flights self.probability_of_extension = probability_of_extension class Closure: # Class for closures def __init__(self, airport, status=False, start=None, end=None, reason=None, update_time=None, notam=None): self.airport = airport self.status = status self.start = start self.end = end self.update_time = update_time self.notam = notam class AirportConfig: # Class for storing airport config data def __init__(self, airport, created_time=None, arrival_runway_config=None, departure_runway_config=None, arrival_rate=None, source_time_stamp=None): self.airport = airport self.created_time = created_time self.arrival_runway_config = arrival_runway_config self.departure_runway_config = departure_runway_config self.arrival_rate = arrival_rate self.source_time_stamp = source_time_stamp class Airport: # Class for storing data for an individual airport def __init__(self, code, session: ClientSession): self.code = code.upper() self.name = None self.latitude = None self.longitude = None self.is_deicing = False self.supported_airport = None self.delay = False self.delay_count = 0 self.ground_delay = GroundDelay(self.code) self.ground_stop = GroundStop(self.code) self.depart_delay = ArriveDepartDelay(self.code) self.arrive_delay = ArriveDepartDelay(self.code) self.closure = Closure(self.code) self.config = None self.session = session async def update(self): resp = await self.session.get(BASE_URL) if resp.status == 200: data = await resp.json() else: raise ClientResponseError( resp.request_info, resp.history, ) # iterate through returned data for correct airport for airport in data: if airport['airportId'] == self.code: self.name = airport['airportLongName'] self.latitude = airport['latitude'] self.longitude = airport['longitude'] if airport['deicing']: self.is_deicing = True # check for each type of delay if airport['groundStop']: self.ground_stop = GroundStop( airport=self.code, status=True, endtime=airport['groundStop']['endTime'], reason=airport['groundStop']['impactingCondition'], update_time=airport['groundStop']['updatedAt'], advisory_url=airport['groundStop']['advisoryUrl'], included_facilities=airport['groundStop']['includedFacilities'], included_flights=airport['groundStop']['includedFlights'], probability_of_extension=airport['groundStop']['probabilityOfExtension'], ) self.delay_count += 1 else: self.GroundStop = GroundStop(self.code) if airport['arrivalDelay']: self.arrive_delay = ArriveDepartDelay( airport=self.code, status=True, minimum=airport['arrivalDelay']['arrivalDeparture']['min'], maximum=airport['arrivalDelay']['arrivalDeparture']['max'], average_delay=airport['arrivalDelay']['averageDelay'], trend=airport['arrivalDelay']['arrivalDeparture']['trend'], reason=airport['arrivalDelay']['reason'], update_time=airport['arrivalDelay']['updateTime'], ) self.delay_count += 1 else: self.arrive_delay = ArriveDepartDelay(self.code) if airport['departureDelay']: self.depart_delay = ArriveDepartDelay( airport=self.code, status=True, minimum=airport['departureDelay']['arrivalDeparture']['min'], maximum=airport['departureDelay']['arrivalDeparture']['max'], average_delay=airport['departureDelay']['averageDelay'], trend=airport['departureDelay']['arrivalDeparture']['trend'], reason=airport['departureDelay']['reason'], update_time=airport['departureDelay']['updateTime'], ) self.delay_count += 1 else: self.depart_delay = ArriveDepartDelay(self.code) if airport['groundDelay']: self.ground_delay = GroundDelay( airport=self.code, status=True, average=airport['groundDelay']['avgDelay'], max_delay=airport['groundDelay']['maxDelay'], start_time=airport['groundDelay']['startTime'], end_time=airport['groundDelay']['endTime'], reason=airport['groundDelay']['impactingCondition'], update_time=airport['groundDelay']['updatedAt'], advisory_url=airport['groundDelay']['advisoryUrl'], departure_scope=airport['groundDelay']['departureScope'], included_facilities=airport['groundDelay']['includedFacilities'], included_flights=airport['groundDelay']['includedFlights'], ) self.delay_count += 1 else: self.ground_delay = GroundDelay(self.code) if airport['airportClosure']: self.closure = Closure( airport=self.code, status=True, start=airport['airportClosure']['startTime'], end=airport['airportClosure']['endTime'], update_time=airport['airportClosure']['updatedAt'], notam=airport['airportClosure']['simpleText'], ) elif airport['freeForm']: # API doesn't always put closures in the actual closure field so check freeform if "CLSD" in airport['freeForm']['simpleText']: self.closure = Closure( airport=self.code, status=True, start=airport['freeForm']['startTime'], end=airport['freeForm']['endTime'], update_time=airport['freeForm']['updatedAt'], notam=airport['freeForm']['simpleText'], ) else: self.closure = Closure(self.code) if self.delay_count > 0: self.delay = True return self # if airport is not in data then no programs are active self.arrive_delay = ArriveDepartDelay(self.code) self.depart_delay = ArriveDepartDelay(self.code) self.ground_stop = GroundStop(self.code) self.ground_delay = GroundDelay(self.code) self.closure = Closure(self.code) async def get_airport_delays(code, session: ClientSession): results = Airport(code, session) await results.update() return results ntilley905-faadelays-4e5098e/pyproject.toml000066400000000000000000000012231450312546300206410ustar00rootroot00000000000000[build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] name = "faadelays" version = "2023.9.1" authors = [ { name="Nathan Tilley", email="nathan@tilley.xyz" }, ] description = "A package to retrieve FAA airport status" readme = "README.md" requires-python = ">=3.7" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] dependencies = [ "aiohttp", ] license = {file = "LICENSE"} [project.urls] "Homepage" = "https://github.com/ntilley905/faadelays" "Bug Tracker" = "https://github.com/ntilley905/faadelays/issues"