Show more detail on space launch page

This commit is contained in:
Edward Betts 2024-01-19 20:35:52 +00:00
parent e475f98dd6
commit e16e04ab51
3 changed files with 41 additions and 11 deletions

View file

@ -22,12 +22,21 @@ def format_list_with_ampersand(items: list[str]) -> str:
return ""
ESA = "AUT,BEL,CZE,DNK,FIN,FRA,DEU,GRC,IRE,ITA,LUZ,NLD,NOR,POL,PRT,ROU,ESP,SWE,CHE,GBR"
def get_country(alpha_2: str) -> pycountry.db.Country | None:
"""Lookup country by alpha-2 country code."""
if alpha_2 == ESA:
return pycountry.db.Country(flag="🇪🇺", name="ESA")
if not alpha_2:
return None
if alpha_2 == "xk":
return pycountry.db.Country(flag="\U0001F1FD\U0001F1F0", name="Kosovo")
country: pycountry.db.Country = pycountry.countries.get(alpha_2=alpha_2.upper())
country: pycountry.db.Country
if len(alpha_2) == 2:
country = pycountry.countries.get(alpha_2=alpha_2.upper())
elif len(alpha_2) == 3:
country = pycountry.countries.get(alpha_3=alpha_2.upper())
return country