airportsdata 20241001__tar.gz → 20250204__tar.gz
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-20241001/airportsdata.egg-info → airportsdata-20250204}/PKG-INFO +40 -51
- {airportsdata-20241001 → airportsdata-20250204}/README.rst +30 -18
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata/__init__.py +11 -20
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata/airports.csv +971 -929
- {airportsdata-20241001 → airportsdata-20250204/airportsdata.egg-info}/PKG-INFO +40 -51
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata.egg-info/SOURCES.txt +2 -2
- airportsdata-20250204/pyproject.toml +280 -0
- airportsdata-20250204/tests/test_airportsdata.py +708 -0
- airportsdata-20241001/MANIFEST.in +0 -5
- airportsdata-20241001/pyproject.toml +0 -138
- {airportsdata-20241001 → airportsdata-20250204}/LICENSE +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata/iata_macs.csv +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata/py.typed +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata.egg-info/dependency_links.txt +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/airportsdata.egg-info/top_level.txt +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/requirements.txt +0 -0
- {airportsdata-20241001 → airportsdata-20250204}/setup.cfg +0 -0
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: airportsdata
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20250204
|
|
4
4
|
Summary: Extensive database of location and timezone data for nearly every airport and landing strip in the world.
|
|
5
5
|
Author-email: Mike Borsetti <mike+airportsdata@borsetti.com>
|
|
6
6
|
Maintainer-email: Mike Borsetti <mike+airportsdata@borsetti.com>
|
|
7
|
-
License:
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2020- Mike Borsetti <mike@borsetti.com>
|
|
10
|
-
|
|
11
|
-
This project includes data from https://github.com/mwgg/Airports Copyright
|
|
12
|
-
(c) 2014 mwgg
|
|
13
|
-
|
|
14
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
in the Software without restriction, including without limitation the rights
|
|
17
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
furnished to do so, subject to the following conditions:
|
|
20
|
-
|
|
21
|
-
The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
copies or substantial portions of the Software.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
SOFTWARE.
|
|
31
|
-
|
|
7
|
+
License-Expression: MIT
|
|
32
8
|
Project-URL: Documentation, https://github.com/mborsetti/airportsdata/blob/main/README.rst
|
|
33
9
|
Project-URL: Repository, https://github.com/mborsetti/airportsdata/
|
|
34
10
|
Project-URL: Database (csv), https://github.com/mborsetti/airportsdata/blob/main/airportsdata/airports.csv
|
|
@@ -37,31 +13,32 @@ Project-URL: Issues, https://github.com/mborsetti/airportsdata/issues
|
|
|
37
13
|
Project-URL: CI, https://github.com/mborsetti/airportsdata/actions
|
|
38
14
|
Keywords: airports,aerodromes,ICAO,IATA
|
|
39
15
|
Classifier: Development Status :: 5 - Production/Stable
|
|
40
|
-
Classifier:
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
41
19
|
Classifier: Programming Language :: Python
|
|
42
20
|
Classifier: Programming Language :: Python :: 3
|
|
43
|
-
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
44
22
|
Classifier: Programming Language :: Python :: 3.10
|
|
45
23
|
Classifier: Programming Language :: Python :: 3.11
|
|
46
24
|
Classifier: Programming Language :: Python :: 3.12
|
|
47
25
|
Classifier: Programming Language :: Python :: 3.13
|
|
48
|
-
Classifier:
|
|
49
|
-
Classifier: Topic :: Database
|
|
50
|
-
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
51
27
|
Classifier: Typing :: Typed
|
|
52
|
-
Requires-Python: >=3.
|
|
28
|
+
Requires-Python: >=3.10
|
|
53
29
|
Description-Content-Type: text/x-rst
|
|
54
30
|
License-File: LICENSE
|
|
31
|
+
Dynamic: license-file
|
|
55
32
|
|
|
56
33
|
========================
|
|
57
34
|
airportsdata |downloads|
|
|
58
35
|
========================
|
|
59
36
|
|
|
60
|
-
.. |ICAO| replace:: 28,
|
|
37
|
+
.. |ICAO| replace:: 28,274
|
|
61
38
|
|
|
62
|
-
.. |IATA| replace:: 7,
|
|
39
|
+
.. |IATA| replace:: 7,865
|
|
63
40
|
|
|
64
|
-
.. |LID| replace:: 12,
|
|
41
|
+
.. |LID| replace:: 12,610
|
|
65
42
|
|
|
66
43
|
.. |pyversion| image:: https://img.shields.io/pypi/v/airportsdata.svg
|
|
67
44
|
:target: https://pypi.org/project/airportsdata/
|
|
@@ -106,16 +83,16 @@ Each entry consists of the following data:
|
|
|
106
83
|
entries);
|
|
107
84
|
* ``iata``: IATA 3-letter Location Code (|IATA| entries) or an empty string [#]_;
|
|
108
85
|
* ``name``: Official name (diacritized latin script);
|
|
109
|
-
* ``city``: City (diacritized latin script), ideally using the local language;
|
|
86
|
+
* ``city``: City (diacritized latin script), ideally using the local language or English;
|
|
110
87
|
* ``subd``: Subdivision (e.g. state, province, region, etc.), ideally using the local-language or English names of
|
|
111
88
|
`ISO 3166-2 <https://en.wikipedia.org/wiki/ISO_3166-2#Current_codes>`__;
|
|
112
89
|
* ``country``: `ISO 3166-1 <https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes>`__ alpha-2 country code
|
|
113
90
|
(plus ``XK`` for Kosovo);
|
|
114
91
|
* ``elevation``: MSL elevation of the highest point of the landing area, in feet (warning: it is often wrong);
|
|
115
92
|
* ``lat``: Latitude (decimal) of the `airport reference point
|
|
116
|
-
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
|
93
|
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 or 6 decimal digits);
|
|
117
94
|
* ``lon``: Longitude (decimal) of the `airport reference point
|
|
118
|
-
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
|
95
|
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 or 6 decimal digits);
|
|
119
96
|
* ``tz``: Timezone expressed as a `tz database name <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`__
|
|
120
97
|
(IANA-compliant);
|
|
121
98
|
* ``lid``: U.S. FAA Location Identifier (|LID| entries), or an empty string.
|
|
@@ -124,8 +101,8 @@ Each entry consists of the following data:
|
|
|
124
101
|
how the Pseudo-ICAO Identifier is generated for airports and seaplane bases without an ICAO 4-letter Location
|
|
125
102
|
Indicator.
|
|
126
103
|
|
|
127
|
-
.. [#] IATA Multi Airport Cities are not not airports and therfore not included, but we provide a database and a
|
|
128
|
-
function that returns the above data for all the airports of a IATA MAC. Please see documentation `here
|
|
104
|
+
.. [#] IATA Multi Airport Cities (MAC) are not not airports and therfore not included, but we provide a database and a
|
|
105
|
+
Python function that returns the above data for all the airports of a IATA MAC. Please see documentation `here
|
|
129
106
|
<https://github.com/mborsetti/airportsdata/blob/main/README_IATA.rst>`__.
|
|
130
107
|
|
|
131
108
|
Best efforts are placed to review all contributions for accuracy, but accuracy cannot be guaranteed nor should be
|
|
@@ -134,7 +111,10 @@ expected by users.
|
|
|
134
111
|
Important notes:
|
|
135
112
|
|
|
136
113
|
* Timezone was originally sourced from `TimeZoneDB <https://timezonedb.com>`__;
|
|
137
|
-
* No historical data (closed airports are removed)
|
|
114
|
+
* No historical data (closed airports are removed);
|
|
115
|
+
* No heliports without a IATA code;
|
|
116
|
+
* No sea bases without a IATA code;
|
|
117
|
+
* No surface transportation stations, even if they have an official IATA code.
|
|
138
118
|
|
|
139
119
|
Please report any issues you may find `here
|
|
140
120
|
<https://github.com/mborsetti/airportsdata/blob/main/CONTRIBUTING.rst>`__.
|
|
@@ -142,7 +122,10 @@ Please report any issues you may find `here
|
|
|
142
122
|
This project is a fork of https://github.com/mwgg/Airports. All new data submitted in this fork have been validated
|
|
143
123
|
against national `Aeronautical Information Publications (AIP) or equivalent
|
|
144
124
|
<https://github.com/mborsetti/airportsdata/blob/main/README_AIP.rst>`__ (or
|
|
145
|
-
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__
|
|
125
|
+
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__ or
|
|
126
|
+
`<https://www.ch-aviation.com/airports/{IATA}>`__ before publishing.
|
|
127
|
+
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__ or
|
|
128
|
+
`<https://www.ch-aviation.com/airports/{IATA}>`_ before publishing.
|
|
146
129
|
|
|
147
130
|
Raw data
|
|
148
131
|
========
|
|
@@ -154,35 +137,41 @@ Python
|
|
|
154
137
|
======
|
|
155
138
|
|pyversion| |support| |format| |status| |security| |CI| |coveralls| |issues|
|
|
156
139
|
|
|
157
|
-
Install from `PyPi <https://pypi.org/project/airportsdata/>`__ using
|
|
140
|
+
Install from `PyPi <https://pypi.org/project/airportsdata/>`__ using ``uv`` (recommended):
|
|
141
|
+
|
|
142
|
+
.. code-block:: bash
|
|
143
|
+
|
|
144
|
+
uv pip install --update airportsdata
|
|
145
|
+
|
|
146
|
+
Or, using ``pip``:
|
|
158
147
|
|
|
159
148
|
.. code-block:: bash
|
|
160
149
|
|
|
161
|
-
pip install
|
|
150
|
+
pip install --update airportsdata
|
|
162
151
|
|
|
163
152
|
Once installed, to load the data into a dict:
|
|
164
153
|
|
|
165
154
|
.. code-block:: python
|
|
166
155
|
|
|
167
156
|
import airportsdata
|
|
168
|
-
|
|
169
|
-
print(
|
|
157
|
+
icao_airports = airportsdata.load() # key is the ICAO identifier (the default)
|
|
158
|
+
print(icao_airports['KJFK'])
|
|
170
159
|
|
|
171
160
|
or
|
|
172
161
|
|
|
173
162
|
.. code-block:: python
|
|
174
163
|
|
|
175
164
|
import airportsdata
|
|
176
|
-
|
|
177
|
-
print(
|
|
165
|
+
iata_airports = airportsdata.load('IATA') # key is the IATA location code
|
|
166
|
+
print(iata_airports['JFK'])
|
|
178
167
|
|
|
179
168
|
or
|
|
180
169
|
|
|
181
170
|
.. code-block:: python
|
|
182
171
|
|
|
183
172
|
import airportsdata
|
|
184
|
-
|
|
185
|
-
print(
|
|
173
|
+
lid_airports = airportsdata.load('LID') # key is the FAA LID
|
|
174
|
+
print(lid_airports['01AA'])
|
|
186
175
|
|
|
187
176
|
Older Python versions are supported for 3 years after being obsoleted by a new major release (i.e. about 4 years
|
|
188
177
|
since their original release).
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
airportsdata |downloads|
|
|
3
3
|
========================
|
|
4
4
|
|
|
5
|
-
.. |ICAO| replace:: 28,
|
|
5
|
+
.. |ICAO| replace:: 28,274
|
|
6
6
|
|
|
7
|
-
.. |IATA| replace:: 7,
|
|
7
|
+
.. |IATA| replace:: 7,865
|
|
8
8
|
|
|
9
|
-
.. |LID| replace:: 12,
|
|
9
|
+
.. |LID| replace:: 12,610
|
|
10
10
|
|
|
11
11
|
.. |pyversion| image:: https://img.shields.io/pypi/v/airportsdata.svg
|
|
12
12
|
:target: https://pypi.org/project/airportsdata/
|
|
@@ -51,16 +51,16 @@ Each entry consists of the following data:
|
|
|
51
51
|
entries);
|
|
52
52
|
* ``iata``: IATA 3-letter Location Code (|IATA| entries) or an empty string [#]_;
|
|
53
53
|
* ``name``: Official name (diacritized latin script);
|
|
54
|
-
* ``city``: City (diacritized latin script), ideally using the local language;
|
|
54
|
+
* ``city``: City (diacritized latin script), ideally using the local language or English;
|
|
55
55
|
* ``subd``: Subdivision (e.g. state, province, region, etc.), ideally using the local-language or English names of
|
|
56
56
|
`ISO 3166-2 <https://en.wikipedia.org/wiki/ISO_3166-2#Current_codes>`__;
|
|
57
57
|
* ``country``: `ISO 3166-1 <https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes>`__ alpha-2 country code
|
|
58
58
|
(plus ``XK`` for Kosovo);
|
|
59
59
|
* ``elevation``: MSL elevation of the highest point of the landing area, in feet (warning: it is often wrong);
|
|
60
60
|
* ``lat``: Latitude (decimal) of the `airport reference point
|
|
61
|
-
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
|
61
|
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 or 6 decimal digits);
|
|
62
62
|
* ``lon``: Longitude (decimal) of the `airport reference point
|
|
63
|
-
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
|
63
|
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 or 6 decimal digits);
|
|
64
64
|
* ``tz``: Timezone expressed as a `tz database name <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`__
|
|
65
65
|
(IANA-compliant);
|
|
66
66
|
* ``lid``: U.S. FAA Location Identifier (|LID| entries), or an empty string.
|
|
@@ -69,8 +69,8 @@ Each entry consists of the following data:
|
|
|
69
69
|
how the Pseudo-ICAO Identifier is generated for airports and seaplane bases without an ICAO 4-letter Location
|
|
70
70
|
Indicator.
|
|
71
71
|
|
|
72
|
-
.. [#] IATA Multi Airport Cities are not not airports and therfore not included, but we provide a database and a
|
|
73
|
-
function that returns the above data for all the airports of a IATA MAC. Please see documentation `here
|
|
72
|
+
.. [#] IATA Multi Airport Cities (MAC) are not not airports and therfore not included, but we provide a database and a
|
|
73
|
+
Python function that returns the above data for all the airports of a IATA MAC. Please see documentation `here
|
|
74
74
|
<https://github.com/mborsetti/airportsdata/blob/main/README_IATA.rst>`__.
|
|
75
75
|
|
|
76
76
|
Best efforts are placed to review all contributions for accuracy, but accuracy cannot be guaranteed nor should be
|
|
@@ -79,7 +79,10 @@ expected by users.
|
|
|
79
79
|
Important notes:
|
|
80
80
|
|
|
81
81
|
* Timezone was originally sourced from `TimeZoneDB <https://timezonedb.com>`__;
|
|
82
|
-
* No historical data (closed airports are removed)
|
|
82
|
+
* No historical data (closed airports are removed);
|
|
83
|
+
* No heliports without a IATA code;
|
|
84
|
+
* No sea bases without a IATA code;
|
|
85
|
+
* No surface transportation stations, even if they have an official IATA code.
|
|
83
86
|
|
|
84
87
|
Please report any issues you may find `here
|
|
85
88
|
<https://github.com/mborsetti/airportsdata/blob/main/CONTRIBUTING.rst>`__.
|
|
@@ -87,7 +90,10 @@ Please report any issues you may find `here
|
|
|
87
90
|
This project is a fork of https://github.com/mwgg/Airports. All new data submitted in this fork have been validated
|
|
88
91
|
against national `Aeronautical Information Publications (AIP) or equivalent
|
|
89
92
|
<https://github.com/mborsetti/airportsdata/blob/main/README_AIP.rst>`__ (or
|
|
90
|
-
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__
|
|
93
|
+
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__ or
|
|
94
|
+
`<https://www.ch-aviation.com/airports/{IATA}>`__ before publishing.
|
|
95
|
+
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__ or
|
|
96
|
+
`<https://www.ch-aviation.com/airports/{IATA}>`_ before publishing.
|
|
91
97
|
|
|
92
98
|
Raw data
|
|
93
99
|
========
|
|
@@ -99,35 +105,41 @@ Python
|
|
|
99
105
|
======
|
|
100
106
|
|pyversion| |support| |format| |status| |security| |CI| |coveralls| |issues|
|
|
101
107
|
|
|
102
|
-
Install from `PyPi <https://pypi.org/project/airportsdata/>`__ using
|
|
108
|
+
Install from `PyPi <https://pypi.org/project/airportsdata/>`__ using ``uv`` (recommended):
|
|
103
109
|
|
|
104
110
|
.. code-block:: bash
|
|
105
111
|
|
|
106
|
-
pip install
|
|
112
|
+
uv pip install --update airportsdata
|
|
113
|
+
|
|
114
|
+
Or, using ``pip``:
|
|
115
|
+
|
|
116
|
+
.. code-block:: bash
|
|
117
|
+
|
|
118
|
+
pip install --update airportsdata
|
|
107
119
|
|
|
108
120
|
Once installed, to load the data into a dict:
|
|
109
121
|
|
|
110
122
|
.. code-block:: python
|
|
111
123
|
|
|
112
124
|
import airportsdata
|
|
113
|
-
|
|
114
|
-
print(
|
|
125
|
+
icao_airports = airportsdata.load() # key is the ICAO identifier (the default)
|
|
126
|
+
print(icao_airports['KJFK'])
|
|
115
127
|
|
|
116
128
|
or
|
|
117
129
|
|
|
118
130
|
.. code-block:: python
|
|
119
131
|
|
|
120
132
|
import airportsdata
|
|
121
|
-
|
|
122
|
-
print(
|
|
133
|
+
iata_airports = airportsdata.load('IATA') # key is the IATA location code
|
|
134
|
+
print(iata_airports['JFK'])
|
|
123
135
|
|
|
124
136
|
or
|
|
125
137
|
|
|
126
138
|
.. code-block:: python
|
|
127
139
|
|
|
128
140
|
import airportsdata
|
|
129
|
-
|
|
130
|
-
print(
|
|
141
|
+
lid_airports = airportsdata.load('LID') # key is the FAA LID
|
|
142
|
+
print(lid_airports['01AA'])
|
|
131
143
|
|
|
132
144
|
Older Python versions are supported for 3 years after being obsoleted by a new major release (i.e. about 4 years
|
|
133
145
|
since their original release).
|
|
@@ -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]},
|