Skip to content

Commit

Permalink
Do not match either way on cargo/non-cargo combos #1439
Browse files Browse the repository at this point in the history
  • Loading branch information
jpatokal committed Sep 7, 2023
1 parent 49300c2 commit 767b0a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/update_airlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ def match(self, wp):
break

# Round 2: Filter out dodgy matches
# TODO: This should be a filter inside Round 1 so it can try again after a failing match...

# Name does not match, might be sus
if match and airline['name'].upper() != name.upper():

# Do not match cargo subsidiaries against parents
if "Cargo" in name and "Cargo" not in airline['name']:
# Do not match cargo subsidiaries against parents, or vice versa
if ("Cargo" in name and "Cargo" not in airline['name']) or ("Cargo" not in name and "Cargo" in airline['name']):
return None, None

# Do not match an inactive airline with a different name against a currently active one
Expand Down
5 changes: 5 additions & 0 deletions tools/update_airlines_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def testCargoSubsidiaryNoMatch(self):
wp = {'icao': 'ABC', 'iata': 'AB', 'name': 'Åland Cargo Airlines', 'callsign': 'ZZZZZ', 'country': 'Åland', 'active': 'Y', 'source': 'Wikidata'}
self.assertNoMatches(wp)

def testCargoParentNoMatch(self):
self.of['name'] = 'Åland Cargo Airlines'
wp = {'icao': 'ABC', 'iata': 'AB', 'name': 'Åland Airlines', 'callsign': 'ZZZZZ', 'country': 'Åland', 'active': 'Y', 'source': 'Wikidata'}
self.assertNoMatches(wp)

def testIgnoreInactiveToActiveChange(self):
wp = {'icao': 'ABC', 'iata': 'AB', 'name': 'Åland Airlines', 'callsign': 'ALAXA', 'country': 'Åland', 'source': 'Wikidata', 'active': 'N', 'end_date': '2019-01-01'}
self.assertOnlyChange(wp, diff={'end_date': '2019-01-01'})
Expand Down

0 comments on commit 767b0a3

Please sign in to comment.