Created
August 31, 2011 12:30
-
-
Save misja/1183424 to your computer and use it in GitHub Desktop.
Set json data as an attribute in a tweepy Status object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import json | |
@classmethod | |
def parse(cls, api, raw): | |
status = cls.first_parse(api, raw) | |
setattr(status, 'json', json.dumps(raw)) | |
return status | |
tweepy.models.Status.first_parse = tweepy.models.Status.parse | |
tweepy.models.Status.parse = parse |
Works, and also can be tweaked to return a dict with:
setattr(status, 'AsDict', raw)
similar to python-twitter (except its an attributive and not a method).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks, very clean solution and works like a charm!