airportsdata 20240806__py3-none-any.whl → 20250204__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airportsdata/__init__.py +11 -20
- airportsdata/airports.csv +968 -920
- {airportsdata-20240806.dist-info → airportsdata-20250204.dist-info}/METADATA +44 -51
- airportsdata-20250204.dist-info/RECORD +9 -0
- {airportsdata-20240806.dist-info → airportsdata-20250204.dist-info}/WHEEL +1 -1
- airportsdata-20240806.dist-info/RECORD +0 -9
- {airportsdata-20240806.dist-info → airportsdata-20250204.dist-info/licenses}/LICENSE +0 -0
- {airportsdata-20240806.dist-info → airportsdata-20250204.dist-info}/top_level.txt +0 -0
airportsdata/__init__.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"""
|
|
4
4
|
Extensive database of location and timezone data for nearly every airport and landing strip in the world.
|
|
5
5
|
"""
|
|
6
|
+
|
|
6
7
|
from __future__ import annotations
|
|
7
8
|
|
|
8
9
|
import csv
|
|
@@ -10,8 +11,8 @@ from pathlib import Path
|
|
|
10
11
|
from typing import Dict, Literal, TypedDict
|
|
11
12
|
|
|
12
13
|
__project_name__ = __package__
|
|
13
|
-
__min_python_version__ = (3,
|
|
14
|
-
__version__ = '
|
|
14
|
+
__min_python_version__ = (3, 10) # minimum version of Python required to run; supported until October 2025
|
|
15
|
+
__version__ = '20250204' # numbering follows the release date (UTC)
|
|
15
16
|
__author__ = 'Mike Borsetti <mike@borsetti.com>'
|
|
16
17
|
__copyright__ = 'Copyright 2020- Mike Borsetti'
|
|
17
18
|
__license__ = 'MIT'
|
|
@@ -57,14 +58,6 @@ def load(code_type: CodeType = 'ICAO') -> Dict[str, 'Airport']:
|
|
|
57
58
|
Originally sourced from [TimeZoneDB](https://timezonedb.com)
|
|
58
59
|
'lid': The FAA Location Identifier (for US country only; others is blank)
|
|
59
60
|
"""
|
|
60
|
-
# with open(os.path.join(dir, 'airports.json'), encoding='utf8') as f:
|
|
61
|
-
# airports = json.load(f)
|
|
62
|
-
# if code_type.lower() == 'icao':
|
|
63
|
-
# return airports
|
|
64
|
-
# else:
|
|
65
|
-
# return {airport['iata']: airport for airport in dict(airports).values() if airport['iata']}
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
61
|
key = code_type.lower()
|
|
69
62
|
if key not in ('icao', 'iata', 'lid'):
|
|
70
63
|
raise ValueError(f'code_type must be one of ICAO, IATA or LID; received {code_type}')
|
|
@@ -73,7 +66,9 @@ def load(code_type: CodeType = 'ICAO') -> Dict[str, 'Airport']:
|
|
|
73
66
|
with this_dir.joinpath('airports.csv').open(encoding='utf8') as f:
|
|
74
67
|
reader = csv.DictReader(f, quoting=csv.QUOTE_NONNUMERIC)
|
|
75
68
|
for row in reader:
|
|
76
|
-
|
|
69
|
+
# if row[key] and row[key] in airports:
|
|
70
|
+
# raise ValueError(f"Duplicate key in csv: '{row[key]}'")
|
|
71
|
+
airports[row[key]] = row
|
|
77
72
|
airports.pop('', None)
|
|
78
73
|
return airports
|
|
79
74
|
|
|
@@ -88,18 +83,14 @@ def load_iata_macs() -> dict[str, IATAMAC]:
|
|
|
88
83
|
'airports': a dict with the same data returned by load() for each airport that makes up the Multi Airport
|
|
89
84
|
City, where the key is the airport's IATA code.
|
|
90
85
|
"""
|
|
91
|
-
# with open(os.path.join(dir, 'airports.json'), encoding='utf8') as f:
|
|
92
|
-
# airports = json.load(f)
|
|
93
|
-
# if code_type.lower() == 'icao':
|
|
94
|
-
# return airports
|
|
95
|
-
# else:
|
|
96
|
-
# return {airport['iata']: airport for airport in dict(airports).values() if airport['iata']}
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
86
|
airports = load('IATA')
|
|
100
87
|
this_dir = Path(__file__).parent
|
|
101
88
|
iata_macs: dict[str, IATAMAC] = {}
|
|
102
89
|
row_d: dict[str, str]
|
|
90
|
+
multi_airport_city_code = ''
|
|
91
|
+
name = ''
|
|
92
|
+
country = ''
|
|
93
|
+
airport = ''
|
|
103
94
|
with this_dir.joinpath('iata_macs.csv').open(encoding='utf8') as f:
|
|
104
95
|
reader = csv.DictReader(f, quoting=csv.QUOTE_NONNUMERIC)
|
|
105
96
|
for row_d in reader:
|
|
@@ -113,7 +104,7 @@ def load_iata_macs() -> dict[str, IATAMAC]:
|
|
|
113
104
|
elif key == 'Airport Code':
|
|
114
105
|
airport = value
|
|
115
106
|
if multi_airport_city_code not in iata_macs:
|
|
116
|
-
iata_macs[multi_airport_city_code] = {
|
|
107
|
+
iata_macs[multi_airport_city_code] = {
|
|
117
108
|
'name': name,
|
|
118
109
|
'country': country,
|
|
119
110
|
'airports': {airport: airports[airport]},
|