def parse(cls, api, json): """Add some stuff to the parse routine.""" status = super(Tweet, cls).parse(api, json) try: tid = status.retweeted_status.id txt = status.retweeted_status.text name = status.retweeted_status.user.name screen_name = status.retweeted_status.user.screen_name is_retweet = True except AttributeError: try: tid = status.id txt = status.text name = status.user.name screen_name = status.user.screen_name is_retweet = False except AttributeError: raise TwitterError( "Found a non status update. (Probably a favourite notification)" ) rtname = status.user.name rtscreen_name = status.user.screen_name setattr(status, 'tid', tid) setattr(status, 'txt_unescaped', unescape(txt)) setattr(status, 'name', unescape(name)) setattr(status, 'screen_name', screen_name) setattr(status, 'rtname', unescape(rtname)) setattr(status, 'rtscreen_name', rtscreen_name) setattr(status, 'is_retweet', is_retweet) setattr(status, 'txt_unescaped', status.txt_unescaped) setattr(status, 'txt', status.expand_urls(status.txt_unescaped)) setattr(status, 'source', unescape(status.source)) return status
def parse(cls, api, json): """Add some stuff to the parse routine.""" status = super(Tweet, cls).parse(api, json) try: tid = status.retweeted_status.id txt = status.retweeted_status.text name = status.retweeted_status.user.name screen_name = status.retweeted_status.user.screen_name is_retweet = True except AttributeError: try: tid = status.id txt = status.text name = status.user.name screen_name = status.user.screen_name is_retweet = False except AttributeError: raise TwitterError( "Found a non status update. (Probably a favourite notification)" ) rtname = status.user.name rtscreen_name = status.user.screen_name url = 'https://twitter.com/{user}/status/{id}'.format(user=screen_name, id=tid) setattr(status, 'tid', tid) setattr(status, 'txt_unescaped', unescape(txt)) setattr(status, 'name', unescape(name)) setattr(status, 'screen_name', screen_name) setattr(status, 'rtname', unescape(rtname)) setattr(status, 'rtscreen_name', rtscreen_name) setattr(status, 'is_retweet', is_retweet) setattr(status, 'txt_unescaped', status.txt_unescaped) setattr(status, 'txt', status.expand_urls(status.txt_unescaped)) setattr(status, 'source', unescape(status.source)) setattr(status, 'url', url) return status
def parse(cls, api, json): user = super(Tweep, cls).parse(api, json) user.name = unescape(user.name) user.description = unescape(user.description) user.location = unescape(user.location) return user