Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def do_request(self):
filt = filter_handler(self.filter)
if self.select.__class__ is list:
self.select = ','.join(self.select)
if not isinstance(self.cursor_max, (type(None), int)):
raise ValueError("cursor_max must be of class int")
payload = {'query':self.query, 'filter':filt, 'offset':self.offset,
'rows':self.limit, 'sample':self.sample, 'sort':self.sort,
'order':self.order, 'facet':self.facet, 'select':self.select,
'cursor':self.cursor}
payload = dict((k, v) for k, v in payload.items() if v)
# add query filters
payload.update(filter_dict(self.kwargs))
# rename query filters
payload = rename_query_filters(payload)
js = self._req(payload = payload)
cu = js['message'].get('next-cursor')
max_avail = js['message']['total-results']
res = self._redo_req(js, payload, cu, max_avail)
return res
if cursor_max.__class__.__name__ != 'NoneType':
if cursor_max.__class__ != int:
raise ValueError("cursor_max must be of class int")
filt = filter_handler(filter)
if select.__class__ is list:
select = ','.join(select)
payload = {'query':query, 'filter':filt, 'offset':offset,
'rows':limit, 'sample':sample, 'sort':sort,
'order':order, 'facet':facet, 'select':select,
'cursor':cursor}
payload = dict((k, v) for k, v in payload.items() if v)
# add query filters
payload.update(filter_dict(kwargs))
# rename query filters
payload = rename_query_filters(payload)
if(ids.__class__.__name__ == 'NoneType'):
url = url.strip("/")
try:
r = requests.get(url, params = payload, headers = make_ua(mailto, ua_string))
r.raise_for_status()
except requests.exceptions.HTTPError:
if is_json(r):
raise RequestError(r.status_code, parse_json_err(r))
else:
r.raise_for_status()
except requests.exceptions.RequestException as e:
raise e
check_json(r)