def create_nation_fixtures(self):
SHP_SLUG = "<STR_LIT>".format(self.YEAR)<EOL>DOWNLOAD_PATH = os.path.join(self.DOWNLOAD_DIRECTORY, SHP_SLUG)<EOL>shape = shapefile.Reader(<EOL>os.path.join(DOWNLOAD_PATH, "<STR_LIT>".format(SHP_SLUG))<EOL>)<EOL>fields = shape.fields[<NUM_LIT:1>:]<EOL>field_names = [f[<NUM_LIT:0>] for f in fields]<EOL>features = []<EOL>for shp in shape.shapeRecords():<EOL><INDENT>state = dict(zip(field_names, shp.record))<EOL>geodata = {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": shp.shape.__geo_interface__,<EOL>"<STR_LIT>": {<EOL>"<STR_LIT:state>": state["<STR_LIT>"],<EOL>"<STR_LIT:name>": state["<STR_LIT>"],<EOL>},<EOL>}<EOL>features.append(geodata)<EOL><DEDENT>Geometry.objects.update_or_create(<EOL>division=self.NATION,<EOL>subdivision_level=self.STATE_LEVEL,<EOL>simplification=self.THRESHOLDS["<STR_LIT>"],<EOL>source=os.path.join(<EOL>self.SHP_SOURCE_BASE.format(self.YEAR), SHP_SLUG<EOL>)<EOL>+ "<STR_LIT>",<EOL>series=self.YEAR,<EOL>defaults={<EOL>"<STR_LIT>": self.toposimplify(<EOL>geojson.FeatureCollection(features),<EOL>self.THRESHOLDS["<STR_LIT>"],<EOL>)<EOL>},<EOL>)<EOL>geo, created = Geometry.objects.update_or_create(<EOL>division=self.NATION,<EOL>subdivision_level=self.COUNTY_LEVEL,<EOL>simplification=self.THRESHOLDS["<STR_LIT>"],<EOL>source=os.path.join(<EOL>self.SHP_SOURCE_BASE.format(self.YEAR), SHP_SLUG<EOL>)<EOL>+ "<STR_LIT>",<EOL>series=self.YEAR,<EOL>defaults={"<STR_LIT>": self.get_state_county_shps("<STR_LIT>")},<EOL>)<EOL>tqdm.write("<STR_LIT>")<EOL>tqdm.write(<EOL>self.TQDM_PREFIX<EOL>+ "<STR_LIT>".format(<EOL>"<STR_LIT>", round(len(json.dumps(geo.topojson)) / <NUM_LIT:1000>)<EOL>)<EOL>)<EOL>tqdm.write(self.style.SUCCESS("<STR_LIT>"))<EOL>
Create national US and State Map