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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from logging import getLogger
  5. log = getLogger('facebook.objects')
  6.  
  7. class Alerts(object):
  8.     stuff = [
  9.         'num_msgs',
  10.         'msgs_time',
  11.         'num_pokes',
  12.         'pokes_time',
  13.         'num_shares',
  14.         'shares_time',
  15.         'friend_requests',
  16.         'group_invites',
  17.         'event_invites']
  18.     urls = dict(msgs = 'http://www.facebook.com/inbox/', pokes = 'http://www.facebook.com/home.php', shares = 'http://www.facebook.com/posted.php', friend_requests = 'http://www.facebook.com/reqs.php', group_invites = 'http://www.facebook.com/reqs.php#group', event_invites = 'http://www.facebook.com/?sk=events')
  19.     
  20.     def __init__(self, fb = None, notifications_get_xml = None):
  21.         log.debug('type(notifications_get_xml) ==> %r', type(notifications_get_xml))
  22.         self.fb = fb
  23.         if notifications_get_xml is not None:
  24.             log.debug('here')
  25.             t = notifications_get_xml
  26.             self.num_msgs = int(t.messages.unread)
  27.             self.msgs_time = int(t.messages.most_recent)
  28.             self.num_pokes = int(t.pokes.unread)
  29.             self.pokes_time = int(t.pokes.most_recent)
  30.             self.num_shares = int(t.shares.unread)
  31.             self.shares_time = int(t.shares.most_recent)
  32.             self.friend_requests = set((lambda .0: for uid in .0:
  33. int(uid))(t.friend_requests))
  34.             self.group_invites = set((lambda .0: for gid in .0:
  35. int(gid))(t.group_invites))
  36.             self.event_invites = set((lambda .0: for eid in .0:
  37. int(eid))(t.event_invites))
  38.         else:
  39.             self.num_msgs = 0
  40.             self.msgs_time = 0
  41.             self.num_pokes = 0
  42.             self.pokes_time = 0
  43.             self.num_shares = 0
  44.             self.shares_time = 0
  45.             self.friend_requests = set()
  46.             self.group_invites = set()
  47.             self.event_invites = set()
  48.             log.debug('there')
  49.  
  50.     
  51.     def __repr__(self):
  52.         pformat = pformat
  53.         import pprint
  54.         s = []([ (a, getattr(self, a)) for a in self.stuff ])
  55.         return '<Alerts %s>' % s
  56.  
  57.     
  58.     def __sub__(self, other):
  59.         ret = Alerts(self.fb)
  60.         for attr in self.stuff:
  61.             setattr(ret, attr, getattr(self, attr) - getattr(other, attr))
  62.         
  63.         return ret
  64.  
  65.     
  66.     def __cmp__(self, other):
  67.         if type(self) != type(other):
  68.             return 1
  69.         for attr in self.stuff:
  70.             if getattr(self, attr) != getattr(other, attr):
  71.                 if not self.num_all - other.num_all:
  72.                     pass
  73.                 return 1
  74.         
  75.         return 0
  76.  
  77.     
  78.     def num_all(self):
  79.         return sum([
  80.             self.num_msgs,
  81.             self.num_pokes,
  82.             self.num_shares,
  83.             len(self.friend_requests),
  84.             len(self.group_invites),
  85.             len(self.event_invites)])
  86.  
  87.     num_all = property(num_all)
  88.     
  89.     def count(self):
  90.         return sum([
  91.             self['num_msgs'],
  92.             self['num_pokes'],
  93.             self['num_shares'],
  94.             self['num_friend_requests'],
  95.             self['num_group_invites'],
  96.             self['num_event_invites']])
  97.  
  98.     count = property(count)
  99.     
  100.     def num_friend_requests(self):
  101.         return len(self.friend_requests)
  102.  
  103.     num_friend_requests = property(num_friend_requests)
  104.     
  105.     def num_group_invites(self):
  106.         return len(self.group_invites)
  107.  
  108.     num_group_invites = property(num_group_invites)
  109.     
  110.     def num_event_invites(self):
  111.         return len(self.event_invites)
  112.  
  113.     num_event_invites = property(num_event_invites)
  114.     
  115.     def __nonzero__(self):
  116.         return (any,)((lambda .0: for attr in .0:
  117. getattr(self, attr))(self.stuff))
  118.  
  119.     
  120.     def __getitem__(self, key):
  121.         if not hasattr(self, 'fb') or self.fb is None:
  122.             raise KeyError(key)
  123.         self.fb is None
  124.         return self.fb.filters['alerts'][key] * getattr(self, key)
  125.  
  126.  
  127.