From f4d4a205f136c6373c415657dd35b4f078f25c69 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Mon, 15 Nov 2010 11:59:09 +0000 Subject: a few renamings, and some other stuff --- src/contact.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/contact.py') diff --git a/src/contact.py b/src/contact.py index 1eb41f72..8341d4b8 100644 --- a/src/contact.py +++ b/src/contact.py @@ -15,12 +15,15 @@ # along with Poezio. If not, see . """ -Defines the Resource and Contact classes +Defines the Resource and Contact classes, which are used in +the roster """ -from sleekxmpp.xmlstream.stanzabase import JID + import logging log = logging.getLogger(__name__) +from sleekxmpp.xmlstream.stanzabase import JID + class Resource(object): """ Defines a roster item. @@ -80,8 +83,7 @@ class Contact(object): def get_highest_priority_resource(self): """ - There must be, at any time, at least ONE resource. - And they always should be ordered by priority. + Return the resource with the highest priority """ ret = None for resource in self._resources: @@ -94,8 +96,10 @@ class Contact(object): Called, for example, when a new resource get offline (the first, or any subsequent one) """ - # TODO sort by priority + def f(o): + return o.get_priority() self._resources.append(resource) + self._resources = sorted(self._resources, key=f, reverse=True) def remove_resource(self, resource): """ -- cgit v1.2.3