01234567890123456789012345678901234567890123456789012345678901234567890123456789
19111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951 | <----SKIPPED LINES----> derived_attributes = {} if not this_flight_number: return derived_attributes potential_values = { 'origin_friendly': [], 'origin_iata': [], 'destination_friendly': [], 'destination_iata': [], 'airline_call_sign': [], 'airline_short_name': [], 'airline_full_name': [] } def AppendIfPresent(k, flight): val = flight.get(k) if val and val != KEY_NOT_PRESENT_STRING: potential_values[k].append(val) for flight in flights: flight_number = flights.get('flight_number') if flight_number: if flight_number == this_flight_number: AppendIfPresent('origin_friendly', flight) AppendIfPresent('origin_iata', flight) AppendIfPresent('destination_friendly', flight) AppendIfPresent('destination_iata', flight) if flight_number[:3] == this_flight_number[:3]: AppendIfPresent('airline_call_sign', flight) AppendIfPresent('airline_short_name', flight) AppendIfPresent('airline_full_name', flight) def Mode(lst): freq = {} for val in lst: freq[val] = freq.get(val, 0) + 1 max_freq = max(freq.values()) for val in freq: if freq[val] == max_freq: return val return None <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
19111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951 | <----SKIPPED LINES----> derived_attributes = {} if not this_flight_number: return derived_attributes potential_values = { 'origin_friendly': [], 'origin_iata': [], 'destination_friendly': [], 'destination_iata': [], 'airline_call_sign': [], 'airline_short_name': [], 'airline_full_name': [] } def AppendIfPresent(k, flight): val = flight.get(k) if val and val != KEY_NOT_PRESENT_STRING: potential_values[k].append(val) for flight in flights: flight_number = flight.get('flight_number') if flight_number: if flight_number == this_flight_number: AppendIfPresent('origin_friendly', flight) AppendIfPresent('origin_iata', flight) AppendIfPresent('destination_friendly', flight) AppendIfPresent('destination_iata', flight) if flight_number[:3] == this_flight_number[:3]: AppendIfPresent('airline_call_sign', flight) AppendIfPresent('airline_short_name', flight) AppendIfPresent('airline_full_name', flight) def Mode(lst): freq = {} for val in lst: freq[val] = freq.get(val, 0) + 1 max_freq = max(freq.values()) for val in freq: if freq[val] == max_freq: return val return None <----SKIPPED LINES----> |