- return int(self.headers.getheader('X-RateLimit-Reset'))
-
-
-# Multiple inheritance makes my inner Java nerd cry. Why can't I just
-# add arbitrary attributes to list or str objects?! Guido, we need to
-# talk.
-class TwitterJsonListResponse(TwitterResponse, list):
- __doc__ = """Twitter JSON Response
- """ + TwitterResponse.__doc__
- def __init__(self, lst, headers):
- TwitterResponse.__init__(self, headers)
- list.__init__(self, lst)
-class TwitterJsonDictResponse(TwitterResponse, dict):
- __doc__ = """Twitter JSON Response
- """ + TwitterResponse.__doc__
- def __init__(self, d, headers):
- TwitterResponse.__init__(self, headers)
- dict.__init__(self, d)
-
-class TwitterXmlResponse(TwitterResponse, str):
- __doc__ = """Twitter XML Response
- """ + TwitterResponse.__doc__
+ return int(self.headers.get('X-Rate-Limit-Reset', "0"))
+
+
+class TwitterDictResponse(dict, TwitterResponse):
+ pass
+
+
+class TwitterListResponse(list, TwitterResponse):
+ pass
+
+
+def wrap_response(response, headers):
+ response_typ = type(response)
+ if response_typ is dict:
+ res = TwitterDictResponse(response)
+ res.headers = headers
+ elif response_typ is list:
+ res = TwitterListResponse(response)
+ res.headers = headers
+ else:
+ res = response
+ return res