diff options
author | mathieui <mathieui@mathieui.net> | 2020-05-28 21:31:18 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-06-01 09:09:09 +0200 |
commit | c9e219c1405604f2ef81b3e446cc33a0492af42d (patch) | |
tree | 70a184a22724be16ce7a7ef930d07e9eda203ade /poezio/roster.py | |
parent | 4fae01c09a286809f046c4347fa799f79a2cc129 (diff) | |
download | poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.gz poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.bz2 poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.xz poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.zip |
mypy: Reduce errors on muctab.py by a lot
Diffstat (limited to 'poezio/roster.py')
-rw-r--r-- | poezio/roster.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/poezio/roster.py b/poezio/roster.py index bedf477b..4a6350a9 100644 --- a/poezio/roster.py +++ b/poezio/roster.py @@ -10,6 +10,8 @@ Defines the Roster and RosterGroup classes import logging log = logging.getLogger(__name__) +from typing import List + from poezio.config import config from poezio.contact import Contact from poezio.roster_sorting import SORTING_METHODS, GROUP_SORTING_METHODS @@ -18,6 +20,7 @@ from os import path as p from datetime import datetime from poezio.common import safeJID from slixmpp.exceptions import IqError, IqTimeout +from slixmpp import JID class Roster: @@ -29,6 +32,22 @@ class Roster: DEFAULT_FILTER = (lambda x, y: None, None) def __init__(self): + self.__node = None + + # A tuple(function, *args) function to filter contacts + # on search, for example + self.contact_filter = self.DEFAULT_FILTER + self.groups = {} + self.contacts = {} + self.length = 0 + self.connected = 0 + self.folded_groups = [] + + # Used for caching roster infos + self.last_built = datetime.now() + self.last_modified = datetime.now() + + def reset(self): """ node: the RosterSingle from slixmpp """ @@ -143,7 +162,7 @@ class Roster: """Subscribe to a jid""" self.__node.subscribe(jid) - def jids(self): + def jids(self) -> List[JID]: """List of the contact JIDS""" l = [] for key in self.__node.keys(): @@ -335,11 +354,6 @@ class RosterGroup: return len([1 for contact in self.contacts if len(contact)]) -def create_roster(): - "Create the global roster object" - global roster - roster = Roster() - # Shared roster object -roster = None +roster = Roster() |