F1 circuit layouts with year-by-year SVGs — manually traced track variations
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

31 lines
862B

  1. from dataclasses import dataclass
  2. from typing import TYPE_CHECKING
  3. from .circuit import Circuit
  4. if TYPE_CHECKING:
  5. from .country import Country
  6. @dataclass
  7. class Locality:
  8. slug: str
  9. name: str
  10. country: 'Country'
  11. circuits: dict[str, Circuit]
  12. @classmethod
  13. def from_dict(cls, country: 'Country', slug: str, data: dict):
  14. locality = cls(
  15. slug=slug,
  16. name=data["name"],
  17. country=country,
  18. circuits={}
  19. )
  20. locality.circuits = {circuit_slug: Circuit.from_dict(locality, circuit_slug, circuit_data) for
  21. circuit_slug, circuit_data in data["circuits"].items()}
  22. return locality
  23. def load_geo_json_data(self):
  24. """Load data for all circuits"""
  25. for circuit in self.circuits.values():
  26. circuit.load_geo_json_data()