Commit cee802b6 authored by mathieui's avatar mathieui

Fix the last pylint error (do not set the roster contact filter to None)

parent 858e3332
......@@ -21,21 +21,22 @@ from datetime import datetime
from poezio.common import safeJID
from slixmpp.exceptions import IqError, IqTimeout
class Roster(object):
The proxy class to get the roster from slixmpp.
Caches Contact and RosterGroup objects.
DEFAULT_FILTER = (lambda x, y: None, None)
def __init__(self):
node: the RosterSingle from slixmpp
self.__node = None
self.contact_filter = None # A tuple(function, *args)
# function to filter contacts,
# on search, for example
# A tuple(function, *args) function to filter contacts
# on search, for example
self.contact_filter = self.DEFAULT_FILTER
self.folded_groups = set(config.get('folded_roster_groups',
self.groups = {}
......@@ -170,7 +171,7 @@ class Roster(object):
contact_list = []
for contact in self.get_contacts():
if contact.bare_jid != self.jid:
if self.contact_filter:
if self.contact_filter is not self.DEFAULT_FILTER:
if self.contact_filter[0](contact, self.contact_filter[1]):
......@@ -297,8 +298,13 @@ class RosterGroup(object):
def get_contacts(self, contact_filter=None, sort=''):
"""Return the group contacts, filtered and sorted"""
contact_list = self.contacts.copy() if not contact_filter\
else [contact for contact in self.contacts.copy() if contact_filter[0](contact, contact_filter[1])]
if contact_filter is Roster.DEFAULT_FILTER or contact_filter is None:
contact_list = self.contacts.copy()
contact_list = [contact
for contact in self.contacts.copy()
if contact_filter[0](contact, contact_filter[1])
contact_list = sorted(contact_list, key=SORTING_METHODS['name'])
for sorting in sort.split(':'):
......@@ -1239,7 +1239,7 @@ class RosterInfoTab(Tab):
def on_search_terminate(self, txt):
roster.contact_filter = None
roster.contact_filter = roster.DEFAULT_FILTER
return True
......@@ -93,25 +93,25 @@ class RosterWin(Win):
log.debug('The roster has changed, rebuilding the cache…')
# This is a search
if roster.contact_filter:
if roster.contact_filter is not roster.DEFAULT_FILTER:
self.roster_cache = []
sort = config.get('roster_sort', 'jid:show') or 'jid:show'
for contact in roster.get_contacts_sorted_filtered(sort):
show_offline = config.get('roster_show_offline') or roster.contact_filter
show_offline = config.get('roster_show_offline')
sort = config.get('roster_sort') or 'jid:show'
group_sort = config.get('roster_group_sort') or 'name'
self.roster_cache = []
# build the cache
for group in roster.get_groups(group_sort):
contacts_filtered = group.get_contacts(roster.contact_filter)
contacts_filtered = group.get_contacts()
if (not show_offline and group.get_nb_connected_contacts() == 0) or not contacts_filtered:
continue # Ignore empty groups
if group.folded:
continue # ignore folded groups
for contact in group.get_contacts(roster.contact_filter, sort):
for contact in group.get_contacts(sort=sort):
if not show_offline and len(contact) == 0:
continue # ignore offline contacts
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment