-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathops.py
31 lines (27 loc) · 911 Bytes
/
ops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
def get_ops(icao):
"""
Uses the DATIS API to get the current airport operations at the airport
It ignores L and R because it does not matter at any of the airports
"""
attempt = requests.get(f'https://datis.clowd.io/api/{icao}')
atis = attempt.json()[0]['datis']
# 14: is used so that ARR/DEP at the beginning of some ATISes are not caught
before, middle, after = atis[14:].partition("DEP")
arr_runway = ""
dep_runway = ""
found_digit = False
for x in range(len(before) - 1, 0, -1):
if before[x].isdigit():
found_digit = True
arr_runway = before[x] + arr_runway
elif found_digit:
break
found_digit = False
for x in after:
if x.isdigit():
found_digit = True
dep_runway += x
elif found_digit:
break
return dep_runway, arr_runway