F1 circuit layouts with year-by-year SVGs — manually traced track variations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
603B

  1. import json
  2. from pathlib import Path
  3. from models.country import Country
  4. def load_circuits_json(file_path: Path, load_geo_data: bool=False) -> dict[str, Country]:
  5. with open(file_path) as f:
  6. return parse_circuits_json(json.load(f), load_geo_data)
  7. def parse_circuits_json(data: dict, load_geo_data: bool=False) -> dict[str, Country]:
  8. countries = {}
  9. for country_slug, country_data in data.items():
  10. countries[country_slug] = Country.from_dict(country_slug, country_data)
  11. if load_geo_data:
  12. countries[country_slug].load_geo_json_data()
  13. return countries