Coverage for fmc/country_of_ICAO.py: 11%
9 statements
« prev ^ index » next coverage.py v7.8.1, created at 2025-05-23 08:53 +0000
« prev ^ index » next coverage.py v7.8.1, created at 2025-05-23 08:53 +0000
1#!/usr/bin/env python3
3# Define function ...
4def country_of_ICAO(
5 airports,
6 icao,
7 /,
8):
9 """Find the country of an airport
11 Parameters
12 ----------
13 airports : list
14 the list of all of the airports
15 icao : str
16 the ICAO code of the desired airport
18 Returns
19 -------
20 country : str
21 the country of the airport
23 Notes
24 -----
25 Copyright 2016 Thomas Guymer [1]_
27 References
28 ----------
29 .. [1] FMC, https://github.com/Guymer/fmc
30 """
32 # **************************************************************************
34 # Catch special cases ...
35 if icao == "EDDT": # This airport closed on 4/May/2021.
36 return "Germany"
38 # Loop over all airports ...
39 for airport in airports:
40 # Skip this airport if it does not have an ICAO code ...
41 if "ICAO" not in airport:
42 continue
44 # Check if this is the correct one and return it's country ...
45 if airport["ICAO"] == icao:
46 return airport["ISO 3166-1 English Short Name"]
48 # Return default if it was not found ...
49 return "ERROR"