fix type of returns variable in get_events: it's a dict if jid is not given

This commit is contained in:
Yann Leboulanger 2007-09-21 23:56:11 +00:00
parent 164a21a0b2
commit 91a3cc11de
1 changed files with 5 additions and 2 deletions

View File

@ -160,12 +160,14 @@ class Events:
return self._get_nb_events(types = types, account = account) return self._get_nb_events(types = types, account = account)
def get_events(self, account, jid = None, types = []): def get_events(self, account, jid = None, types = []):
'''if event is not specified, get all events from this jid, '''returns all events from the given account of the form
{jid1: [], jid2: []}
if jid is given, returns all events from the given jid in a list: []
optionnaly only from given type''' optionnaly only from given type'''
if not self._events.has_key(account): if not self._events.has_key(account):
return [] return []
events_list = [] # list of events
if not jid: if not jid:
events_list = {} # list of events
for jid_ in self._events[account]: for jid_ in self._events[account]:
events = [] events = []
for ev in self._events[account][jid_]: for ev in self._events[account][jid_]:
@ -176,6 +178,7 @@ class Events:
return events_list return events_list
if not self._events[account].has_key(jid): if not self._events[account].has_key(jid):
return [] return []
events_list = [] # list of events
for ev in self._events[account][jid]: for ev in self._events[account][jid]:
if not types or ev.type_ in types: if not types or ev.type_ in types:
events_list.append(ev) events_list.append(ev)