Changeset 923:fe2a902681bc for src


Ignore:
Timestamp:
04/27/19 12:11:14 (6 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Eliminated calls to cmp() (re #347).

Location:
src/mlx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/timetable.py

    r919 r923  
    752752        planes = [plane for plane in fleet
    753753                  if plane.aircraftType == aircraftType]
    754         planes.sort(cmp = lambda p1, p2: cmp(p1.tailNumber, p2.tailNumber))
     754        planes.sort(key = lambda p: p.tailNumber)
    755755
    756756        dialog = BookDialog(self, flightPair, planes)
  • src/mlx/rpc.py

    r919 r923  
    111111                cs1 = int(self.callsign[2:])
    112112                cs2 = int(other.callsign[2:])
    113                 return cmp(cs1, cs2)
     113                return 0 if cs1==cs2 else -1 if cs1<cs2 else 1
    114114            except:
    115                 return cmp(self.callsign, other.callsign)
     115                return 0 if self.callsign==other.callsign \
     116                    else -1 if self.callsign<other.callsign else 1
    116117        else:
    117             return cmp(getattr(self, name), getattr(other, name))
     118            v1 = getattr(self, name)
     119            v2 = getattr(other, name)
     120            return 0 if v1==v2 else -1 if v1<v2 else 1
    118121
    119122    def __repr__(self):
     
    166169                flightPairs.append(ScheduledFlightPair(flight))
    167170
    168         flightPairs.sort(cmp = lambda pair1, pair2:
    169                          cmp(pair1.flight0.date, pair2.flight0.date))
     171        flightPairs.sort(key = lambda pair: pair.flight0.date)
    170172
    171173        return flightPairs
     
    523525
    524526        for flights in [bookedFlights, reportedFlights, rejectedFlights]:
    525             flights.sort(cmp = lambda flight1, flight2:
    526                          cmp(flight1.departureTime, flight2.departureTime))
     527            flights.sort(key = lambda flight: flight.departureTime)
    527528
    528529        return (bookedFlights, reportedFlights, rejectedFlights)
  • src/mlx/web.py

    r919 r923  
    791791                result.flights.append(flight)
    792792
    793             result.flights.sort(cmp = lambda flight1, flight2:
    794                                 cmp(flight1.departureTime,
    795                                     flight2.departureTime))
     793            result.flights.sort(key = lambda flight: flight.departureTime)
    796794
    797795        f.close()
Note: See TracChangeset for help on using the changeset viewer.