Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self.get(fields, geo=geo, **kwargs)
@supported_years(2017, 2016, 2015, 2014, 2013, 2012, 2011)
def zipcode(self, fields, zcta, **kwargs):
return self.get(fields, geo={
'for': 'zip code tabulation area:{}'.format(zcta),
}, **kwargs)
class ACS5DpClient(ACS5Client):
dataset = 'acs5/profile'
years = (2017, 2016, 2015, 2014, 2013, 2012)
class ACS3Client(ACSClient):
default_year = 2013
dataset = 'acs3'
years = (2013, 2012)
@supported_years()
def state_county_subdivision(self, fields, state_fips,
county_fips, subdiv_fips, **kwargs):
return self.get(fields, geo={
'for': 'county subdivision:{}'.format(subdiv_fips),
'in': 'state:{} county:{}'.format(state_fips, county_fips),
}, **kwargs)
class ACS3DpClient(ACS3Client):
else:
self.endpoint_url = super(ACSClient, self).endpoint_url
self.definitions_url = super(ACSClient, self).definitions_url
self.definition_url = super(ACSClient, self).definition_url
self.groups_url = super(ACSClient, self).groups_url
def tables(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(ACSClient, self).tables(*args, **kwargs)
def get(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(ACSClient, self).get(*args, **kwargs)
class ACS5Client(ACSClient):
default_year = 2017
dataset = 'acs5'
years = (2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
@supported_years()
def state_county_subdivision(self, fields, state_fips,
county_fips, subdiv_fips, **kwargs):
return self.get(fields, geo={
'for': 'county subdivision:{}'.format(subdiv_fips),
'in': 'state:{} county:{}'.format(state_fips, county_fips),
}, **kwargs)
@supported_years()
def state_county_tract(self, fields, state_fips,
years = (2013, 2012)
@supported_years()
def state_county_subdivision(self, fields, state_fips,
county_fips, subdiv_fips, **kwargs):
return self.get(fields, geo={
'for': 'county subdivision:{}'.format(subdiv_fips),
'in': 'state:{} county:{}'.format(state_fips, county_fips),
}, **kwargs)
class ACS3DpClient(ACS3Client):
dataset = 'acs3/profile'
class ACS1Client(ACSClient):
default_year = 2017
dataset = 'acs1'
years = (2017, 2016, 2015, 2014, 2013, 2012, 2011)
@supported_years()
def state_county_subdivision(self, fields, state_fips,
county_fips, subdiv_fips, **kwargs):
return self.get(fields, geo={
'for': 'county subdivision:{}'.format(subdiv_fips),
'in': 'state:{} county:{}'.format(state_fips, county_fips),
}, **kwargs)
class ACS1DpClient(ACS1Client):
def _switch_endpoints(self, year):
if year > 2009:
self.endpoint_url = 'https://api.census.gov/data/%s/acs/%s'
self.definitions_url = 'https://api.census.gov/data/%s/acs/%s/variables.json'
self.definition_url = 'https://api.census.gov/data/%s/acs/%s/variables/%s.json'
self.groups_url = 'https://api.census.gov/data/%s/acs/%s/groups.json'
else:
self.endpoint_url = super(ACSClient, self).endpoint_url
self.definitions_url = super(ACSClient, self).definitions_url
self.definition_url = super(ACSClient, self).definition_url
self.groups_url = super(ACSClient, self).groups_url