diff --git a/src/Misc.py b/src/Misc.py index 08e2f8af7..489b376a2 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -77,8 +77,8 @@ class Misc(callbacks.Privmsg): callAfter = utils.Everything() callBefore = utils.Nothing() - def __cmp__(self, other): - return 1 # We should always be the last plugin. + def __lt__(self, other): + return False # We should always be the last plugin. def invalidCommand(self, irc, msg, tokens): self.log.debug('Misc.invalidCommand called (tokens %s)', tokens) diff --git a/src/Owner.py b/src/Owner.py index 0867026f1..1c24851be 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -228,8 +228,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): callAfter = utils.Nothing() callBefore = utils.Everything() - def __cmp__(self, other): - return -1 # We should always be the first plugin. + def __lt__(self, other): + return True # We should always be the first plugin. def _getIrc(self, network): network = network.lower() diff --git a/src/callbacks.py b/src/callbacks.py index abdcda0f9..5d2958e4a 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -933,18 +933,19 @@ class Privmsg(irclib.IrcCallback): # attributes which are lists of plugin names which the plugin should be # called before and after, respectively. We may, at some future point, # remove priority entirely. - def __cmp__(self, other): + def __lt__(self, other): selfName = self.name() otherName = other.name() # We can't be certain of the order the callbacks list is in, so we - # can't be certain that our __cmp__ is the most specific one, so + # can't be certain that our __lt__ is the most specific one, so # we basically run the other callback's as well. if isinstance(other, Privmsg): - if otherName in self.callAfter or selfName in other.callBefore: - return 1 - elif otherName in self.callBefore or selfName in other.callAfter: - return -1 - return self.__parent.__cmp__(other) + if other.name() in self.callBefore or \ + self.name() in other.callAfter: + return True + else: + return False + return self.__parent.__lt__(other) def __call__(self, irc, msg): if msg.command == 'PRIVMSG': diff --git a/src/irclib.py b/src/irclib.py index 0b23d4ea6..6f6f27a76 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -82,19 +82,19 @@ class IrcCallback(IrcCommandDispatcher): __firewalled__ = {'die': None, 'reset': None, '__call__': None, - '__cmp__': lambda self: 0, + '__lt__': lambda self: 0, 'inFilter': lambda self, irc, msg: msg, 'outFilter': lambda self, irc, msg: msg, 'name': lambda self: self.__class__.__name__,} - def __cmp__(self, other): + def __lt__(self, other): if isinstance(other, IrcCallback): - ret = cmp(self.priority, other.priority) - if ret == 0: - ret = cmp(self.name(), other.name()) + ret = self.priority < other.priority + if not ret: + ret = self.name() < other.name() return ret else: - return super(IrcCallback, self).__cmp__(other) + return super(IrcCallback, self).__lt__(other) def name(self): """Returns the name of the callback."""