hack in support for retweets in the Status

This commit is contained in:
Brian S. Stephan 2010-12-16 13:02:37 -06:00
parent 1bacfe047e
commit e2989b639c

View File

@ -110,6 +110,7 @@ class Status(object):
status.place status.place
status.coordinates status.coordinates
status.contributors status.contributors
status.retweeted_status
''' '''
def __init__(self, def __init__(self,
created_at=None, created_at=None,
@ -130,7 +131,8 @@ class Status(object):
geo=None, geo=None,
place=None, place=None,
coordinates=None, coordinates=None,
contributors=None): contributors=None,
retweeted_status=None):
'''An object to hold a Twitter status message. '''An object to hold a Twitter status message.
This class is normally instantiated by the twitter.Api class and This class is normally instantiated by the twitter.Api class and
@ -177,6 +179,7 @@ class Status(object):
self.place = place self.place = place
self.coordinates = coordinates self.coordinates = coordinates
self.contributors = contributors self.contributors = contributors
self.retweeted_status = retweeted_status
def GetCreatedAt(self): def GetCreatedAt(self):
'''Get the time this status message was posted. '''Get the time this status message was posted.
@ -471,7 +474,8 @@ class Status(object):
self.geo == other.geo and \ self.geo == other.geo and \
self.place == other.place and \ self.place == other.place and \
self.coordinates == other.coordinates and \ self.coordinates == other.coordinates and \
self.contributors == other.contributors self.contributors == other.contributors and \
self.retweeted_status == other.retweeted_status
except AttributeError: except AttributeError:
return False return False
@ -545,6 +549,10 @@ class Status(object):
Returns: Returns:
A twitter.Status instance A twitter.Status instance
''' '''
if not data:
return None
if 'user' in data: if 'user' in data:
user = User.NewFromJsonDict(data['user']) user = User.NewFromJsonDict(data['user'])
else: else:
@ -576,7 +584,8 @@ class Status(object):
geo=data.get('geo', None), geo=data.get('geo', None),
place=data.get('place', None), place=data.get('place', None),
coordinates=data.get('coordinates', None), coordinates=data.get('coordinates', None),
contributors=data.get('contributors', None)) contributors=data.get('contributors', None),
retweeted_status=Status.NewFromJsonDict(data.get('retweeted_status', None)))
class User(object): class User(object):