home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from common.protocolmeta import protocols
- from itertools import islice
-
- def first(iterable):
-
- try:
- return islice(iterable, 1).next()
- except StopIteration:
- return None
-
-
-
- def im_service_compatible(to_service, from_service):
- return to_service in protocols[from_service].compatible
-
-
- def choose_to(metacontact):
- return metacontact.first_online
-
-
- def choose_from(contact, accounts, tofrom):
- acct = lookup_tofrom_account(contact, accounts, tofrom)
- if acct is not None:
- return acct
- for account in accounts:
- if account.connection is contact.protocol:
- return account
-
- return first(compatible_im_accounts(contact, accounts))
-
-
- def lookup_tofrom_account(contact, connected_accounts, tofrom):
- name = contact.name
- service = contact.service
- for bname, bservice, fromname, fromservice in tofrom:
- if name == bname and service == bservice:
- for acct in connected_accounts:
- if acct.name == fromname and acct.service == fromservice:
- return acct
-
- acct.service == fromservice
-
-
-
- def compatible_im_accounts(contact, accounts):
- for account in accounts:
- to_service = contact.service
- from_service = account.protocol
- if im_service_compatible(to_service, from_service):
- yield account
- continue
-
-
-