# Parse the response payload
return_cursors = (return_cursors or
'cursor' in self.session.params or 'next' in self.session.params)
- result = parser.parse(self, resp.text, api=api,
- payload_list=payload_list,
+ result = parser.parse(resp.text, api=api, payload_list=payload_list,
payload_type=payload_type,
return_cursors=return_cursors)
# This is a special invocation that returns the underlying
# APIMethod class
- model = ModelParser().parse(self.method(create=True), data,
- payload_list=self.method.payload_list,
- payload_type=self.method.payload_type)
+ model = ModelParser().parse(
+ data, payload_list=self.method.payload_list,
+ payload_type=self.method.payload_type
+ )
result = self.method.__self__.parser.parse(
- self.method(create=True), data,
- payload_list=self.method.payload_list,
+ data, payload_list=self.method.payload_list,
payload_type=self.method.payload_type
)
class Parser:
- def parse(self, method, payload, *args, **kwargs):
+ def parse(self, payload, *args, **kwargs):
"""
Parse the response payload and return the result.
Returns a tuple that contains the result data and the cursors
def __init__(self):
pass
- def parse(self, method, payload, *args, **kwargs):
+ def parse(self, payload, *args, **kwargs):
return payload
def parse_error(self, payload):
payload_format = 'json'
- def parse(self, method, payload, *, return_cursors=False, **kwargs):
+ def parse(self, payload, *, return_cursors=False, **kwargs):
try:
json = json_lib.loads(payload)
except Exception as e:
JSONParser.__init__(self)
self.model_factory = model_factory or ModelFactory
- def parse(self, method, payload, *, api=None, payload_list=False,
+ def parse(self, payload, *, api=None, payload_list=False,
payload_type=None, return_cursors=False):
try:
if payload_type is None:
except AttributeError:
raise TweepError(f'No model for this payload type: {payload_type}')
- json = JSONParser.parse(self, method, payload, return_cursors=return_cursors)
+ json = JSONParser.parse(self, payload, return_cursors=return_cursors)
if isinstance(json, tuple):
json, cursors = json
else: