Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'get': ",".join(fields),
'for': geo['for'],
'key': self._key,
}
if 'in' in geo:
params['in'] = geo['in']
resp = self.session.get(url, params=params)
if resp.status_code == 200:
try:
data = resp.json()
except ValueError as ex:
if '<title>Invalid Key</title>' in resp.text:
raise APIKeyError(' '.join(resp.text.splitlines()))
else:
raise ex
headers = data.pop(0)
types = [self._field_type(header, year) for header in headers]
results = [{header : (cast(item) if item is not None else None)
for header, cast, item
in zip(headers, types, d)}
for d in data]
return results
elif resp.status_code == 204:
return []
else:
raise CensusException(resp.text)