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

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def country_of_ICAO( 

5 airports, 

6 icao, 

7 /, 

8): 

9 """Find the country of an airport 

10 

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 

17 

18 Returns 

19 ------- 

20 country : str 

21 the country of the airport 

22 

23 Notes 

24 ----- 

25 Copyright 2016 Thomas Guymer [1]_ 

26 

27 References 

28 ---------- 

29 .. [1] FMC, https://github.com/Guymer/fmc 

30 """ 

31 

32 # ************************************************************************** 

33 

34 # Catch special cases ... 

35 if icao == "EDDT": # This airport closed on 4/May/2021. 

36 return "Germany" 

37 

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 

43 

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"] 

47 

48 # Return default if it was not found ... 

49 return "ERROR"