fix: add BER to airports.py so scans include Berlin Brandenburg
All checks were successful
Deploy / deploy (push) Successful in 21s
All checks were successful
Deploy / deploy (push) Successful in 21s
OpenFlights dataset predates BER's 2020 opening. The patch already existed in api_server.py for the search UI, but scan_processor.py uses airports.py directly, so Germany scans silently skipped BER. Added _MISSING_AIRPORTS to airports.py, patched both get_airports_for_country() and _all_airports_by_iata() to inject the extras, making BER available to scans and lookups. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,13 @@ COUNTRY_NAME_TO_ISO = {
|
||||
}
|
||||
|
||||
|
||||
# Airports missing from the OpenFlights dataset (opened or renamed after dataset was last updated).
|
||||
# Keyed by ISO country code; dicts match the airports_by_country.json schema (iata/name/city/icao).
|
||||
_MISSING_AIRPORTS: dict[str, list[dict]] = {
|
||||
'DE': [{'iata': 'BER', 'name': 'Berlin Brandenburg Airport', 'city': 'Berlin', 'icao': 'EDDB'}],
|
||||
}
|
||||
|
||||
|
||||
def country_name_to_iso_code(country_name: str) -> Optional[str]:
|
||||
"""
|
||||
Convert country name to ISO 2-letter code.
|
||||
@@ -197,7 +204,12 @@ def get_airports_for_country(country_code: str) -> list[dict]:
|
||||
f"Available codes (sample): {', '.join(available)}..."
|
||||
)
|
||||
|
||||
return airports_by_country[country_code]
|
||||
result = list(airports_by_country[country_code])
|
||||
existing_iatas = {a['iata'] for a in result}
|
||||
for extra in _MISSING_AIRPORTS.get(country_code, []):
|
||||
if extra['iata'] not in existing_iatas:
|
||||
result.append(extra)
|
||||
return result
|
||||
|
||||
|
||||
def resolve_airport_list(country: Optional[str], from_airports: Optional[str]) -> list[dict]:
|
||||
@@ -233,11 +245,16 @@ def _all_airports_by_iata() -> dict:
|
||||
download_and_build_airport_data()
|
||||
with open(AIRPORTS_JSON_PATH, 'r', encoding='utf-8') as f:
|
||||
airports_by_country = json.load(f)
|
||||
return {
|
||||
result = {
|
||||
a['iata']: a
|
||||
for airports in airports_by_country.values()
|
||||
for a in airports
|
||||
}
|
||||
for extras in _MISSING_AIRPORTS.values():
|
||||
for extra in extras:
|
||||
if extra['iata'] not in result:
|
||||
result[extra['iata']] = extra
|
||||
return result
|
||||
|
||||
|
||||
def lookup_airport(iata: str) -> dict | None:
|
||||
|
||||
Reference in New Issue
Block a user