home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from util import Storage
- from datetime import datetime
- from util import soupify, odict
- from logging import getLogger
- log = getLogger('yahoo360')
- info = log.info
- from util.BeautifulSoup import BeautifulStoneSoup
- FEED_TEXT = u'New RSS Feed'
-
- def handle(yahoo, y360xml, updates_cb = None):
- log.info(y360xml)
- s = BeautifulStoneSoup(y360xml, convertEntities = BeautifulStoneSoup.ALL_ENTITIES, fromEncoding = 'utf-8')
- if not s or not (s.mingle):
- return None
- G = globals()
- updates = []
- for buddy in s.mingle.vitality.findAll('buddy'):
- vitals = buddy.findAll('vital')
- buddyobj = yahoo.buddies[buddy['id']]
-
- try:
- buddyobj.setnotifyif('y360hash', buddy['hash'])
- except KeyError:
- not (s.mingle)
- not (s.mingle)
- buddyobj.setnotifyif('y360hash', buddy['u'][len('http://360.yahoo.com/profile-'):])
- except:
- not (s.mingle)
-
- for vital in vitals:
- vitaltype = 'vital_' + vital['p'][:-1]
- print 'vitaltype', vitaltype
- if vitaltype in G:
- url = vital.get('u', profile_link(buddy['hash']))
- vid = int(vital['id'])
- cdata = vital.renderContents(None)
- content = None if cdata.strip() else ''
- if vitaltype == 'vital_feeds':
- old_updates = buddyobj.y360updates
- if old_updates:
- for update, tstamp in list(old_updates):
- if update[1].startswith(FEED_TEXT):
- old_updates.remove((update, tstamp))
- continue
-
-
-
- updates.append((G[vitaltype](url, vid, content), int(vital['t'])))
- continue
- log.warning('unhandled 360 vital %s', vitaltype)
-
- if updates:
- if updates_cb:
- return updates_cb(updates)
- log.info('received %d yahoo 360 updates for %s', len(updates), buddy['id'])
- ups = list(buddyobj.y360updates)
- [](_[1])
- buddyobj.setnotifyif('y360updates', ups)
- continue
- []
-
-
-
- def profile_link(hash):
- return 'http://360.yahoo.com/profile-' + hash
-
-
- def vital_blog(url, vid, content):
- return (url, u'New Blog Post' + content)
-
-
- def vital_feeds(url, vid, content):
- return (url, FEED_TEXT + content)
-
-
- def vital_profile(url, vid, content):
- if vid == 2:
- text = u'New Blast' + content
- else:
- text = u'Updated Profile' + content
- return (url, text)
-
-
- def vital_lists(url, vid, content):
- return (url, u'New Lists' + content)
-
- if __name__ == '__main__':
- s = '\n<mingle><vitality base-url="http://360.yahoo.com" expire-mins="48">\n <buddy id="digsby02" d="9" hash="ZrlqYs41cqED_oUFxKyvYg--" p="profile-">\n <vital id="2" t="1177094411" p="profile-"/>\n </buddy>\n <buddy id="digsby02" d="9" hash="ZrlqYs41cqED_oUFxKyvYg--" p="profile-"/>\n <buddy id="penultimatefire" d="9" hash="lM75WJshfqj_SUhuW3jIElKMsMlyxDg-" p="profile-"/>\n</vitality></mingle>'
- from pprint import pprint
- handle(None, s, (lambda u: pprint(u)))
-
-