Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
coll = r.json()
else:
if(ids.__class__.__name__ == "str"):
ids = ids.split()
if(ids.__class__.__name__ == "int"):
ids = [ids]
coll = []
for i in range(len(ids)):
if works:
res = Request(mailto, ua_string, url, str(ids[i]) + "/works",
query, filter, offset, limit, sample, sort,
order, facet, select, cursor, cursor_max, None,
progress_bar, **kwargs).do_request()
coll.append(res)
else:
if agency:
endpt = url + str(ids[i]) + "/agency"
else:
endpt = url + str(ids[i])
endpt = endpt.strip("/")
try:
r = requests.get(endpt, params = payload, headers = make_ua(mailto, ua_string))
r.raise_for_status()
except requests.exceptions.HTTPError:
## the string is additional because it's added to the UA string we send in every request
## turn on verbose curl output to see the request headers sent
x = Crossref(ua_string = "foo bar")
x
x.works(ids = '10.1371/journal.pone.0033693')
## unset the additional user-agent string
x = Crossref()
x.works(ids = '10.1371/journal.pone.0033693')
'''
if ids.__class__.__name__ != 'NoneType':
return request(self.mailto, self.ua_string, self.base_url, "/works/", ids,
query, filter, offset, limit, sample, sort,
order, facet, select, None, None, None, None,
progress_bar, **kwargs)
else:
return Request(self.mailto, self.ua_string, self.base_url, "/works/",
query, filter, offset, limit, sample, sort,
order, facet, select, cursor, cursor_max, None,
progress_bar, **kwargs).do_request()