F1 circuit layouts with year-by-year SVGs — manually traced track variations
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

19 行
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