X-Git-Url: https://projects.mako.cc/source/twitter-api-cdsw-solutions/blobdiff_plain/4c43c9724c25c3d919cb535973559fab1f1c0a7b..1b5bb6edc34a0c0f3b4e3b97a7df8aa709ba9c9e:/tweepy/parsers.py diff --git a/tweepy/parsers.py b/tweepy/parsers.py index 31e0022..bccb032 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -2,6 +2,8 @@ # Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. +from __future__ import print_function + from tweepy.models import ModelFactory from tweepy.utils import import_simplejson from tweepy.error import TweepError @@ -51,10 +53,12 @@ class JSONParser(Parser): except Exception as e: raise TweepError('Failed to parse JSON payload: %s' % e) - needsCursors = method.parameters.has_key('cursor') - if needsCursors and isinstance(json, dict) and 'previous_cursor' in json and 'next_cursor' in json: - cursors = json['previous_cursor'], json['next_cursor'] - return json, cursors + needs_cursors = 'cursor' in method.session.params + if needs_cursors and isinstance(json, dict): + if 'previous_cursor' in json: + if 'next_cursor' in json: + cursors = json['previous_cursor'], json['next_cursor'] + return json, cursors else: return json @@ -74,10 +78,12 @@ class ModelParser(JSONParser): def parse(self, method, payload): try: - if method.payload_type is None: return + if method.payload_type is None: + return model = getattr(self.model_factory, method.payload_type) except AttributeError: - raise TweepError('No model for this payload type: %s' % method.payload_type) + raise TweepError('No model for this payload type: ' + '%s' % method.payload_type) json = JSONParser.parse(self, method, payload) if isinstance(json, tuple): @@ -94,4 +100,3 @@ class ModelParser(JSONParser): return result, cursors else: return result -