feat(scrapers): simplify structure

This commit is contained in:
Barrett Ruth 2025-09-22 22:44:08 -04:00
parent 3b768cc6c4
commit 89440e5d14
3 changed files with 14 additions and 109 deletions

View file

@ -11,20 +11,11 @@ from .models import (
TestsResult,
)
ALL_SCRAPERS: dict[str, type[BaseScraper]] = {
"atcoder": AtCoderScraper,
"codeforces": CodeforcesScraper,
"cses": CSESScraper,
}
_SCRAPER_CLASSES = [
__all__ = [
"AtCoderScraper",
"BaseScraper",
"CodeforcesScraper",
"CSESScraper",
]
_BASE_EXPORTS = [
"BaseScraper",
"ScraperConfig",
"ContestListResult",
"ContestSummary",
@ -33,34 +24,3 @@ _BASE_EXPORTS = [
"TestCase",
"TestsResult",
]
_REGISTRY_FUNCTIONS = [
"get_scraper",
"list_platforms",
"ALL_SCRAPERS",
]
__all__ = _BASE_EXPORTS + _SCRAPER_CLASSES + _REGISTRY_FUNCTIONS
_exported_types = (
ScraperConfig,
ContestListResult,
ContestSummary,
MetadataResult,
ProblemSummary,
TestCase,
TestsResult,
)
def get_scraper(platform: str) -> type[BaseScraper]:
if platform not in ALL_SCRAPERS:
available = ", ".join(ALL_SCRAPERS.keys())
raise KeyError(
f"Unknown platform '{platform}'. Available platforms: {available}"
)
return ALL_SCRAPERS[platform]
def list_platforms() -> list[str]:
return list(ALL_SCRAPERS.keys())