home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / contacts / tofrom.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  1.7 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from common.protocolmeta import protocols
  5. from itertools import islice
  6.  
  7. def first(iterable):
  8.     
  9.     try:
  10.         return islice(iterable, 1).next()
  11.     except StopIteration:
  12.         return None
  13.  
  14.  
  15.  
  16. def im_service_compatible(to_service, from_service):
  17.     return to_service in protocols[from_service].compatible
  18.  
  19.  
  20. def choose_to(metacontact):
  21.     return metacontact.first_online
  22.  
  23.  
  24. def choose_from(contact, accounts, tofrom):
  25.     acct = lookup_tofrom_account(contact, accounts, tofrom)
  26.     if acct is not None:
  27.         return acct
  28.     for account in accounts:
  29.         if account.connection is contact.protocol:
  30.             return account
  31.     
  32.     return first(compatible_im_accounts(contact, accounts))
  33.  
  34.  
  35. def lookup_tofrom_account(contact, connected_accounts, tofrom):
  36.     name = contact.name
  37.     service = contact.service
  38.     for bname, bservice, fromname, fromservice in tofrom:
  39.         if name == bname and service == bservice:
  40.             for acct in connected_accounts:
  41.                 if acct.name == fromname and acct.service == fromservice:
  42.                     return acct
  43.             
  44.         acct.service == fromservice
  45.     
  46.  
  47.  
  48. def compatible_im_accounts(contact, accounts):
  49.     for account in accounts:
  50.         to_service = contact.service
  51.         from_service = account.protocol
  52.         if im_service_compatible(to_service, from_service):
  53.             yield account
  54.             continue
  55.     
  56.  
  57.