home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / yahoo / yahoo360.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  3.5 KB  |  95 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from util import Storage
  5. from datetime import datetime
  6. from util import soupify, odict
  7. from logging import getLogger
  8. log = getLogger('yahoo360')
  9. info = log.info
  10. from util.BeautifulSoup import BeautifulStoneSoup
  11. FEED_TEXT = u'New RSS Feed'
  12.  
  13. def handle(yahoo, y360xml, updates_cb = None):
  14.     log.info(y360xml)
  15.     s = BeautifulStoneSoup(y360xml, convertEntities = BeautifulStoneSoup.ALL_ENTITIES, fromEncoding = 'utf-8')
  16.     if not s or not (s.mingle):
  17.         return None
  18.     G = globals()
  19.     updates = []
  20.     for buddy in s.mingle.vitality.findAll('buddy'):
  21.         vitals = buddy.findAll('vital')
  22.         buddyobj = yahoo.buddies[buddy['id']]
  23.         
  24.         try:
  25.             buddyobj.setnotifyif('y360hash', buddy['hash'])
  26.         except KeyError:
  27.             not (s.mingle)
  28.             not (s.mingle)
  29.             buddyobj.setnotifyif('y360hash', buddy['u'][len('http://360.yahoo.com/profile-'):])
  30.         except:
  31.             not (s.mingle)
  32.  
  33.         for vital in vitals:
  34.             vitaltype = 'vital_' + vital['p'][:-1]
  35.             print 'vitaltype', vitaltype
  36.             if vitaltype in G:
  37.                 url = vital.get('u', profile_link(buddy['hash']))
  38.                 vid = int(vital['id'])
  39.                 cdata = vital.renderContents(None)
  40.                 content = None if cdata.strip() else ''
  41.                 if vitaltype == 'vital_feeds':
  42.                     old_updates = buddyobj.y360updates
  43.                     if old_updates:
  44.                         for update, tstamp in list(old_updates):
  45.                             if update[1].startswith(FEED_TEXT):
  46.                                 old_updates.remove((update, tstamp))
  47.                                 continue
  48.                         
  49.                     
  50.                 
  51.                 updates.append((G[vitaltype](url, vid, content), int(vital['t'])))
  52.                 continue
  53.             log.warning('unhandled 360 vital %s', vitaltype)
  54.         
  55.         if updates:
  56.             if updates_cb:
  57.                 return updates_cb(updates)
  58.             log.info('received %d yahoo 360 updates for %s', len(updates), buddy['id'])
  59.             ups = list(buddyobj.y360updates)
  60.             [](_[1])
  61.             buddyobj.setnotifyif('y360updates', ups)
  62.             continue
  63.         []
  64.     
  65.  
  66.  
  67. def profile_link(hash):
  68.     return 'http://360.yahoo.com/profile-' + hash
  69.  
  70.  
  71. def vital_blog(url, vid, content):
  72.     return (url, u'New Blog Post' + content)
  73.  
  74.  
  75. def vital_feeds(url, vid, content):
  76.     return (url, FEED_TEXT + content)
  77.  
  78.  
  79. def vital_profile(url, vid, content):
  80.     if vid == 2:
  81.         text = u'New Blast' + content
  82.     else:
  83.         text = u'Updated Profile' + content
  84.     return (url, text)
  85.  
  86.  
  87. def vital_lists(url, vid, content):
  88.     return (url, u'New Lists' + content)
  89.  
  90. if __name__ == '__main__':
  91.     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>'
  92.     from pprint import pprint
  93.     handle(None, s, (lambda u: pprint(u)))
  94.  
  95.