home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / contacts / identity.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  3.2 KB  |  96 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from util import removedupes
  5.  
  6. class Identity(object):
  7.     __slots__ = [
  8.         'id',
  9.         'alias',
  10.         'groups',
  11.         'buddies']
  12.     
  13.     def __init__(self, id, alias = None, groups = None, buddies = None):
  14.         if groups is None:
  15.             groups = set()
  16.         
  17.         if buddies is None:
  18.             buddies = []
  19.         
  20.         self.id = id
  21.         self.alias = alias
  22.         self.groups = groups
  23.         none_tuple = (None,)
  24.         if (any,)((lambda .0: for g in .0:
  25. g == none_tuple)(groups)):
  26.             raise ValueError('groups had a None')
  27.         (any,)((lambda .0: for g in .0:
  28. g == none_tuple)(groups))
  29.         self.buddies = removedupes(buddies)
  30.  
  31.     
  32.     def serialize(self):
  33.         buds = [ buddy.serialize() for buddy in self.buddies ]
  34.         buds2 = []
  35.         for bud in buds:
  36.             if bud not in buds2:
  37.                 buds2.append(bud)
  38.                 continue
  39.             []
  40.         
  41.         return dict(id = self.id, alias = self.alias, groups = self.groups, buddies = buds2)
  42.  
  43.     
  44.     def unserialize(cls, d):
  45.         buds = [ Personality.unserialize(buddy) for buddy in d['buddies'] ]
  46.         d['buddies'] = buds
  47.         return cls(**d)
  48.  
  49.     unserialize = classmethod(unserialize)
  50.     
  51.     def __repr__(self):
  52.         return '<Identity %r groups: %r, buddies: %r>' % (self.alias, self.groups, self.buddies)
  53.  
  54.  
  55.  
  56. class Personality(object):
  57.     __slots__ = [
  58.         'name',
  59.         'service']
  60.     
  61.     def __init__(self, name, service):
  62.         self.name = name.lower()
  63.         self.service = service
  64.  
  65.     
  66.     def serialize(self):
  67.         return dict(name = self.name.lower(), service = self.service)
  68.  
  69.     
  70.     def tag(self):
  71.         return (self.name.lower(), self.service)
  72.  
  73.     tag = property(tag)
  74.     
  75.     def __hash__(self):
  76.         return hash(self.tag)
  77.  
  78.     
  79.     def __cmp__(self, other):
  80.         if other is self:
  81.             return 0
  82.         if not isinstance(other, type(self)):
  83.             return -1
  84.         return cmp(self.tag, other.tag)
  85.  
  86.     
  87.     def unserialize(cls, d):
  88.         return cls(**d)
  89.  
  90.     unserialize = classmethod(unserialize)
  91.     
  92.     def __repr__(self):
  93.         return '<Personality %s %s>' % (self.name.lower(), self.service)
  94.  
  95.  
  96.