home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from logging import getLogger
- log = getLogger('facebook.objects')
-
- class Alerts(object):
- stuff = [
- 'num_msgs',
- 'msgs_time',
- 'num_pokes',
- 'pokes_time',
- 'num_shares',
- 'shares_time',
- 'friend_requests',
- 'group_invites',
- 'event_invites',
- 'notifications']
- 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')
-
- def __init__(self, fb = None, notifications_get_xml = None, notifications = None):
- log.debug('type(notifications_get_xml) ==> %r', type(notifications_get_xml))
- self.fb = fb
- if notifications_get_xml is not None:
- log.debug('here')
- t = notifications_get_xml
- self.num_msgs = int(t.messages.unread)
- self.msgs_time = int(t.messages.most_recent)
- self.num_pokes = int(t.pokes.unread)
- self.pokes_time = int(t.pokes.most_recent)
- self.num_shares = int(t.shares.unread)
- self.shares_time = int(t.shares.most_recent)
- self.friend_requests = set((lambda .0: for uid in .0:
- int(uid))(t.friend_requests))
- self.group_invites = set((lambda .0: for gid in .0:
- int(gid))(t.group_invites))
- self.event_invites = set((lambda .0: for eid in .0:
- int(eid))(t.event_invites))
- else:
- self.num_msgs = 0
- self.msgs_time = 0
- self.num_pokes = 0
- self.pokes_time = 0
- self.num_shares = 0
- self.shares_time = 0
- self.friend_requests = set()
- self.group_invites = set()
- self.event_invites = set()
- log.debug('there')
- self.update_notifications(notifications)
-
-
- def update_notifications(self, notifications = None):
- if notifications is None:
- notifications = []
-
- self.notifications = set((lambda .0: for n in .0:
- if n.get('title_html', None) is not None and int(n['is_unread']) == 1:
- n['notification_id']continue)(notifications))
-
-
- def __repr__(self):
- pformat = pformat
- import pprint
- s = []([ (a, getattr(self, a)) for a in self.stuff ])
- return '<Alerts %s>' % s
-
-
- def __sub__(self, other):
- ret = Alerts(self.fb)
- for attr in self.stuff:
- setattr(ret, attr, getattr(self, attr) - getattr(other, attr))
-
- return ret
-
-
- def __cmp__(self, other):
- if type(self) != type(other):
- return 1
- for attr in self.stuff:
- if getattr(self, attr) != getattr(other, attr):
- if not self.num_all - other.num_all:
- pass
- return 1
-
- return 0
-
-
- def num_all(self):
- return sum([
- self.num_msgs,
- self.num_pokes,
- self.num_shares,
- len(self.friend_requests),
- len(self.group_invites),
- len(self.event_invites),
- len(self.notifications)])
-
- num_all = property(num_all)
-
- def count(self):
- return sum([
- self['num_msgs'],
- self['num_pokes'],
- self['num_shares'],
- self['num_friend_requests'],
- self['num_group_invites'],
- self['num_event_invites'],
- self['num_notifications']])
-
- count = property(count)
-
- def num_friend_requests(self):
- return len(self.friend_requests)
-
- num_friend_requests = property(num_friend_requests)
-
- def num_group_invites(self):
- return len(self.group_invites)
-
- num_group_invites = property(num_group_invites)
-
- def num_event_invites(self):
- return len(self.event_invites)
-
- num_event_invites = property(num_event_invites)
-
- def num_notifications(self):
- return len(self.notifications)
-
- num_notifications = property(num_notifications)
-
- def __nonzero__(self):
- return (any,)((lambda .0: for attr in .0:
- getattr(self, attr))(self.stuff))
-
-
- def __getitem__(self, key):
- if not hasattr(self, 'fb') or self.fb is None:
- raise KeyError(key)
- self.fb is None
- return self.fb.filters['alerts'][key] * getattr(self, key)
-
-
-