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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from common import profile
  5. from logging import getLogger
  6. log = getLogger('buddyinfo')
  7.  
  8. class BuddyInfo(object):
  9.     __slots__ = [
  10.         'protocol_name',
  11.         'protocol_username',
  12.         'buddy_name']
  13.     
  14.     def __init__(self, buddy):
  15.         protocol = buddy.protocol
  16.         self.protocol_name = protocol.name
  17.         self.protocol_username = protocol.username
  18.         self.buddy_name = buddy.name
  19.  
  20.     
  21.     def __eq__(self, obj):
  22.         s = object()
  23.         for slot in self.__slots__:
  24.             if getattr(self, slot) != getattr(obj, slot, s):
  25.                 return False
  26.         
  27.         return True
  28.  
  29.     
  30.     def __ne__(self, other):
  31.         return not self.__eq__(other)
  32.  
  33.     
  34.     def __hash__(self):
  35.         return hash(('_'.join,)((lambda .0: for slot in .0:
  36. getattr(self, slot))(self.__slots__)))
  37.  
  38.     
  39.     def buddy(self):
  40.         protocol = profile.account_manager.get_im_account(self.protocol_username, self.protocol_name)
  41.         if protocol is None or not (protocol.connected):
  42.             return None
  43.         return protocol.connection.get_buddy(self.buddy_name)
  44.  
  45.     
  46.     def isbuddy(self, buddy):
  47.         if buddy.name == self.buddy_name and buddy.protocol.username == self.protocol_username:
  48.             pass
  49.         return buddy.protocol.name == self.protocol_name
  50.  
  51.     
  52.     def __repr__(self):
  53.         return '<BuddyInfo %s (on %s:%s)>' % (self.buddy_name, self.protocol_name, self.protocol_username)
  54.  
  55.  
  56.  
  57. class binfoproperty(object):
  58.     
  59.     def __init__(self, name, default = sentinel):
  60.         if not isinstance(name, basestring):
  61.             raise TypeError
  62.         isinstance(name, basestring)
  63.         self.name = name
  64.         self.default = default
  65.  
  66.     
  67.     def __get__(self, obj, objtype):
  68.         res = profile.blist.get_contact_info(obj, self.name)
  69.         if res is None and self.default is not sentinel:
  70.             res = self.default()
  71.             log.info('%s: %s not found, placing default %s', obj.name, self.name, res)
  72.             profile.blist.set_contact_info(obj, self.name, res)
  73.         
  74.         return res
  75.  
  76.     
  77.     def __set__(self, obj, value):
  78.         return profile.blist.set_contact_info(obj, self.name, value)
  79.  
  80.  
  81.