"""Twitter API"""
def __init__(self, auth_handler=None, host='twitter.com', cache=None,
- secure=False, api_root='', validate=True,
+ secure=False, api_root='',
retry_count=0, retry_delay=0, retry_errors=None):
# you may access these freely
self.auth_handler = auth_handler
self.api_root = api_root
self.cache = cache
self.secure = secure
- self.validate = validate
self.retry_count = retry_count
self.retry_delay = retry_delay
self.retry_errors = retry_errors
pickle[k] = v
return pickle
- @staticmethod
- def _validate(model, attributes):
- missing = []
- for attr in attributes:
- if not hasattr(model, attr):
- missing.append(attr)
- if len(missing) > 0:
- raise TweepError('Missing required attribute(s) %s' % \
- str(missing).strip('[]'))
-
- def validate(self):
- return
-
class Status(Model):
- @staticmethod
- def _validate(status):
- Model._validate(status, [
- 'created_at', 'id', 'text', 'source', 'truncated', 'in_reply_to_status_id',
- 'in_reply_to_user_id', 'favorited', 'in_reply_to_screen_name'
- ])
- if hasattr(status, 'user'):
- User._validate(status.user)
-
- def validate(self):
- Status._validate(self)
-
def destroy(self):
return self._api.destroy_status(self.id)
class User(Model):
- @staticmethod
- def _validate(user):
- Model._validate(user, [
- 'id', 'name', 'screen_name', 'location', 'description', 'profile_image_url',
- 'url', 'protected', 'followers_count', 'profile_background_color',
- 'profile_text_color', 'profile_sidebar_fill_color',
- 'profile_sidebar_border_color', 'friends_count', 'created_at',
- 'favourites_count', 'utc_offset', 'time_zone',
- 'profile_background_image_url', 'statuses_count',
- 'notifications', 'following', 'verified'
- ])
- if hasattr(user, 'status'):
- Status._validate(user.status)
-
- def validate(self):
- User._validate(self)
-
def timeline(self, **kargs):
return self._api.user_timeline(**kargs)