summaryrefslogtreecommitdiff
path: root/poezio/roster.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-10-13 23:15:03 +0200
committermathieui <mathieui@mathieui.net>2017-10-13 23:15:03 +0200
commitcee802b6efa027702d1e9fbaa6f440b22cc2996b (patch)
tree3073612e9c989b3445c4e431c8bd34278d8f99d5 /poezio/roster.py
parent858e3332791d74c25f0abd7659276ce15db6e1cf (diff)
downloadpoezio-cee802b6efa027702d1e9fbaa6f440b22cc2996b.tar.gz
poezio-cee802b6efa027702d1e9fbaa6f440b22cc2996b.tar.bz2
poezio-cee802b6efa027702d1e9fbaa6f440b22cc2996b.tar.xz
poezio-cee802b6efa027702d1e9fbaa6f440b22cc2996b.zip
Fix the last pylint error (do not set the roster contact filter to None)
Diffstat (limited to 'poezio/roster.py')
-rw-r--r--poezio/roster.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/poezio/roster.py b/poezio/roster.py
index b36442d6..96dfd396 100644
--- a/poezio/roster.py
+++ b/poezio/roster.py
@@ -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',
section='var').split(':'))
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]):
contact_list.append(contact)
else:
@@ -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()
+ else:
+ 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(':'):