home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from hashlib import md5
- from util.primitives.error_handling import traceguard, try_this
- import logging
-
- def signature(secret, **kw):
- return md5(''.join((lambda .0: for k, v in .0:
- '='.join((str(k), str(v))))(sorted(kw.items()))) + secret).hexdigest()
-
-
- def trim_profiles(stream_dict):
- post_profiles = extract_profile_ids(stream_dict)
- trimmed = set()
- for key in stream_dict['profiles']:
- if key not in post_profiles:
- trimmed.add(key)
- continue
-
- profiles_len = len(stream_dict['profiles'])
- for key in trimmed:
- stream_dict['profiles'].pop(key)
-
- if len(trimmed):
- log = logging.getLogger('fbutil').info
- else:
- log = logging.getLogger('fbutil').debug
- log('trimmed %d of %d profiles, %d remain', len(trimmed), profiles_len, len(stream_dict['profiles']))
- log('trimmed %r', trimmed)
- log('profiles %r', stream_dict['profiles'].keys())
-
- POST_ID_NAMES = frozenset(('viewer_id', 'actor_id', 'target_id', 'source_id'))
- IGNORED = (KeyError, IndexError, TypeError)
-
- def extract_profile_ids(stream):
- ret = set()
- for None in stream['posts']:
- post = None
- for None in POST_ID_NAMES:
- key = None
-
- try:
- (traceguard, traceguard.__exit__, try_this)((lambda : ret.add(post[key])), ignore = IGNORED)
- finally:
- pass
-
-
-
- try:
- (traceguard.__exit__, try_this)((lambda : ret.update(post['likes']['sample'])), ignore = IGNORED)
- finally:
- pass
-
- traceguard.__enter__()
-
- try:
- (traceguard.__exit__, try_this)((lambda : ret.update(post['likes']['friends'])), ignore = IGNORED)
- finally:
- pass
-
-
- for post_comments in stream['comments'].values():
- for None in post_comments:
- comment = None
-
- try:
- (traceguard.__exit__, try_this)((lambda : ret.add(comment['fromid'])), ignore = IGNORED)
- finally:
- pass
-
-
-
- for None in stream.get('notifications', []):
- notification = None
-
- try:
- (traceguard.__exit__, try_this)((lambda : ret.add(notification['sender_id'])), ignore = IGNORED)
- finally:
- pass
-
-
- return ret
-
-