Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_contact_list.py @ 2032:d941fa9954f4
quick frontend (contact): fixed roster and roster_connected in handler + add a next function for pyjamas compatibility
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 09 Aug 2016 01:10:09 +0200 |
parents | 7aa58b7a47e2 |
children | 748e539c5feb |
comparison
equal
deleted
inserted
replaced
2031:48a61879f9ef | 2032:d941fa9954f4 |
---|---|
38 | 38 |
39 def max(iterable, key): | 39 def max(iterable, key): |
40 iter_cpy = list(iterable) | 40 iter_cpy = list(iterable) |
41 iter_cpy.sort(key=key) | 41 iter_cpy.sort(key=key) |
42 return pyjamas_max(iter_cpy) | 42 return pyjamas_max(iter_cpy) |
43 | |
44 # next doesn't exist in pyjamas | |
45 def next(iterable, *args): | |
46 try: | |
47 return iterable.next() | |
48 except StopIteration as e: | |
49 if args: | |
50 return args[0] | |
51 raise e | |
52 | |
43 | 53 |
44 handler = None | 54 handler = None |
45 | 55 |
46 | 56 |
47 class ProfileContactList(object): | 57 class ProfileContactList(object): |
594 if entity in contact_list: | 604 if entity in contact_list: |
595 return True | 605 return True |
596 return False | 606 return False |
597 | 607 |
598 @property | 608 @property |
599 def roster_entities(self): | 609 def roster(self): |
600 """Return all the bare JIDs of the roster entities. | 610 """Return all the bare JIDs of the roster entities. |
601 | 611 |
602 @return (set[jid.JID]) | 612 @return (set[jid.JID]) |
603 """ | 613 """ |
604 entities = set() | 614 entities = set() |
605 for contact_list in self._clist.itervalues(): | 615 for contact_list in self._clist.itervalues(): |
606 entities.update(contact_list.roster_entities) | 616 entities.update(contact_list.roster) |
607 return entities | 617 return entities |
608 | 618 |
609 @property | 619 @property |
610 def roster_entities_connected(self): | 620 def roster_connected(self): |
611 """Return all the bare JIDs of the roster entities that are connected. | 621 """Return all the bare JIDs of the roster entities that are connected. |
612 | 622 |
613 @return (set[jid.JID]) | 623 @return (set[jid.JID]) |
614 """ | 624 """ |
615 entities = set() | 625 entities = set() |
616 for contact_list in self._clist.itervalues(): | 626 for contact_list in self._clist.itervalues(): |
617 entities.update(contact_list.roster_entities_connected) | 627 entities.update(contact_list.roster_connected) |
618 return entities | 628 return entities |
619 | 629 |
620 @property | 630 @property |
621 def roster_entities_by_group(self): | 631 def roster_entities_by_group(self): |
622 """Return a dictionary binding the roster groups to their entities bare | 632 """Return a dictionary binding the roster groups to their entities bare |