home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / plugins / facebook / objects.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  5.3 KB  |  145 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.         'notifications']
  19.     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', notifications = 'http://www.facebook.com/notifications.php')
  20.     
  21.     def __init__(self, fb = None, notifications_get_xml = None, notifications = None):
  22.         log.debug('type(notifications_get_xml) ==> %r', type(notifications_get_xml))
  23.         self.fb = fb
  24.         if notifications_get_xml is not None:
  25.             log.debug('here')
  26.             t = notifications_get_xml
  27.             self.num_msgs = int(t.messages.unread)
  28.             self.msgs_time = int(t.messages.most_recent)
  29.             self.num_pokes = int(t.pokes.unread)
  30.             self.pokes_time = int(t.pokes.most_recent)
  31.             self.num_shares = int(t.shares.unread)
  32.             self.shares_time = int(t.shares.most_recent)
  33.             self.friend_requests = set((lambda .0: for uid in .0:
  34. int(uid))(t.friend_requests))
  35.             self.group_invites = set((lambda .0: for gid in .0:
  36. int(gid))(t.group_invites))
  37.             self.event_invites = set((lambda .0: for eid in .0:
  38. int(eid))(t.event_invites))
  39.         else:
  40.             self.num_msgs = 0
  41.             self.msgs_time = 0
  42.             self.num_pokes = 0
  43.             self.pokes_time = 0
  44.             self.num_shares = 0
  45.             self.shares_time = 0
  46.             self.friend_requests = set()
  47.             self.group_invites = set()
  48.             self.event_invites = set()
  49.             log.debug('there')
  50.         self.update_notifications(notifications)
  51.  
  52.     
  53.     def update_notifications(self, notifications = None):
  54.         if notifications is None:
  55.             notifications = []
  56.         
  57.         self.notifications = set((lambda .0: for n in .0:
  58. if n.get('title_html', None) is not None and int(n['is_unread']) == 1:
  59. n['notification_id']continue)(notifications))
  60.  
  61.     
  62.     def __repr__(self):
  63.         pformat = pformat
  64.         import pprint
  65.         s = []([ (a, getattr(self, a)) for a in self.stuff ])
  66.         return '<Alerts %s>' % s
  67.  
  68.     
  69.     def __sub__(self, other):
  70.         ret = Alerts(self.fb)
  71.         for attr in self.stuff:
  72.             setattr(ret, attr, getattr(self, attr) - getattr(other, attr))
  73.         
  74.         return ret
  75.  
  76.     
  77.     def __cmp__(self, other):
  78.         if type(self) != type(other):
  79.             return 1
  80.         for attr in self.stuff:
  81.             if getattr(self, attr) != getattr(other, attr):
  82.                 if not self.num_all - other.num_all:
  83.                     pass
  84.                 return 1
  85.         
  86.         return 0
  87.  
  88.     
  89.     def num_all(self):
  90.         return sum([
  91.             self.num_msgs,
  92.             self.num_pokes,
  93.             self.num_shares,
  94.             len(self.friend_requests),
  95.             len(self.group_invites),
  96.             len(self.event_invites),
  97.             len(self.notifications)])
  98.  
  99.     num_all = property(num_all)
  100.     
  101.     def count(self):
  102.         return sum([
  103.             self['num_msgs'],
  104.             self['num_pokes'],
  105.             self['num_shares'],
  106.             self['num_friend_requests'],
  107.             self['num_group_invites'],
  108.             self['num_event_invites'],
  109.             self['num_notifications']])
  110.  
  111.     count = property(count)
  112.     
  113.     def num_friend_requests(self):
  114.         return len(self.friend_requests)
  115.  
  116.     num_friend_requests = property(num_friend_requests)
  117.     
  118.     def num_group_invites(self):
  119.         return len(self.group_invites)
  120.  
  121.     num_group_invites = property(num_group_invites)
  122.     
  123.     def num_event_invites(self):
  124.         return len(self.event_invites)
  125.  
  126.     num_event_invites = property(num_event_invites)
  127.     
  128.     def num_notifications(self):
  129.         return len(self.notifications)
  130.  
  131.     num_notifications = property(num_notifications)
  132.     
  133.     def __nonzero__(self):
  134.         return (any,)((lambda .0: for attr in .0:
  135. getattr(self, attr))(self.stuff))
  136.  
  137.     
  138.     def __getitem__(self, key):
  139.         if not hasattr(self, 'fb') or self.fb is None:
  140.             raise KeyError(key)
  141.         self.fb is None
  142.         return self.fb.filters['alerts'][key] * getattr(self, key)
  143.  
  144.  
  145.