__init__.py 894 B

12345678910111213141516171819202122232425262728293031
  1. from typing import List, Tuple
  2. from .random_street_view import SOURCE_GROUP as RSV_SOURCE_GROUP
  3. from .shared import ExhaustedSourceError
  4. from ..schemas import GameConfig, GenMethodEnum, CacheInfo
  5. source_groups = {
  6. GenMethodEnum.rsv: RSV_SOURCE_GROUP,
  7. }
  8. def generate_points(config: GameConfig) -> List[Tuple[float, float]]:
  9. """
  10. Generate points according to the GameConfig.
  11. """
  12. return source_groups[config.generation_method].get_points_from(config.rounds, config.country_lock)
  13. def restock_source(generation_method: GenMethodEnum):
  14. """
  15. Restock any caches associated with the generation method.
  16. """
  17. source_groups[generation_method].restock_all()
  18. def get_cache_info() -> List[CacheInfo]:
  19. """
  20. Get CacheInfo for all caches
  21. """
  22. return [CacheInfo(cache_name=c.get_name(), size=len(c.stock)) for g in source_groups.values() for c in g.cached]