Compare commits
3 commits
c4be8b4f9e
...
32a4b2da3b
| Author | SHA1 | Date | |
|---|---|---|---|
| 32a4b2da3b | |||
| 97f6815f7c | |||
| 8485955baa |
2 changed files with 20 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from .base import BaseScraper
|
from .base import BaseScraper, extract_precision
|
||||||
from .timeouts import HTTP_TIMEOUT
|
from .timeouts import HTTP_TIMEOUT
|
||||||
from .models import (
|
from .models import (
|
||||||
ContestListResult,
|
ContestListResult,
|
||||||
|
|
@ -173,6 +173,7 @@ async def _stream_single_problem(client: httpx.AsyncClient, slug: str) -> None:
|
||||||
|
|
||||||
timeout_ms, memory_mb = _parse_limits(html)
|
timeout_ms, memory_mb = _parse_limits(html)
|
||||||
interactive = _is_interactive(html)
|
interactive = _is_interactive(html)
|
||||||
|
precision = extract_precision(html)
|
||||||
|
|
||||||
tests: list[TestCase] = []
|
tests: list[TestCase] = []
|
||||||
try:
|
try:
|
||||||
|
|
@ -200,6 +201,7 @@ async def _stream_single_problem(client: httpx.AsyncClient, slug: str) -> None:
|
||||||
"memory_mb": memory_mb,
|
"memory_mb": memory_mb,
|
||||||
"interactive": interactive,
|
"interactive": interactive,
|
||||||
"multi_test": False,
|
"multi_test": False,
|
||||||
|
"precision": precision,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
flush=True,
|
flush=True,
|
||||||
|
|
@ -254,6 +256,8 @@ class KattisScraper(BaseScraper):
|
||||||
ProblemSummary(id=slug, name=name) for slug, name in slugs
|
ProblemSummary(id=slug, name=name) for slug, name in slugs
|
||||||
],
|
],
|
||||||
url=f"{BASE_URL}/problems/%s",
|
url=f"{BASE_URL}/problems/%s",
|
||||||
|
contest_url=f"{BASE_URL}/contests/{contest_id}",
|
||||||
|
standings_url=f"{BASE_URL}/contests/{contest_id}/standings",
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
html = await _fetch_text(
|
html = await _fetch_text(
|
||||||
|
|
@ -273,6 +277,8 @@ class KattisScraper(BaseScraper):
|
||||||
contest_id=contest_id,
|
contest_id=contest_id,
|
||||||
problems=[ProblemSummary(id=contest_id, name=name)],
|
problems=[ProblemSummary(id=contest_id, name=name)],
|
||||||
url=f"{BASE_URL}/problems/%s",
|
url=f"{BASE_URL}/problems/%s",
|
||||||
|
contest_url=f"{BASE_URL}/problems/{contest_id}",
|
||||||
|
standings_url="",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return self._metadata_error(str(e))
|
return self._metadata_error(str(e))
|
||||||
|
|
@ -373,9 +379,15 @@ class KattisScraper(BaseScraper):
|
||||||
return self._submit_error(f"Submit request failed: {e}")
|
return self._submit_error(f"Submit request failed: {e}")
|
||||||
|
|
||||||
sid_m = re.search(r"Submission ID:\s*(\d+)", r.text, re.IGNORECASE)
|
sid_m = re.search(r"Submission ID:\s*(\d+)", r.text, re.IGNORECASE)
|
||||||
sid = sid_m.group(1) if sid_m else ""
|
if not sid_m:
|
||||||
|
return self._submit_error(
|
||||||
|
r.text.strip() or "Submit failed (no submission ID)"
|
||||||
|
)
|
||||||
return SubmitResult(
|
return SubmitResult(
|
||||||
success=True, error="", submission_id=sid, verdict="submitted"
|
success=True,
|
||||||
|
error="",
|
||||||
|
submission_id=sid_m.group(1),
|
||||||
|
verdict="submitted",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def login(self, credentials: dict[str, str]) -> LoginResult:
|
async def login(self, credentials: dict[str, str]) -> LoginResult:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from typing import Any, cast
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from .base import BaseScraper
|
from .base import BaseScraper, extract_precision
|
||||||
from .timeouts import HTTP_TIMEOUT
|
from .timeouts import HTTP_TIMEOUT
|
||||||
from .models import (
|
from .models import (
|
||||||
ContestListResult,
|
ContestListResult,
|
||||||
|
|
@ -130,12 +130,14 @@ def _parse_problem_page(html: str) -> dict[str, Any]:
|
||||||
memory_mb = int(mm.group(1)) if mm else 256
|
memory_mb = int(mm.group(1)) if mm else 256
|
||||||
|
|
||||||
interactive = "interactive problem" in html.lower()
|
interactive = "interactive problem" in html.lower()
|
||||||
|
precision = extract_precision(html)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"tests": tests,
|
"tests": tests,
|
||||||
"timeout_ms": timeout_ms,
|
"timeout_ms": timeout_ms,
|
||||||
"memory_mb": memory_mb,
|
"memory_mb": memory_mb,
|
||||||
"interactive": interactive,
|
"interactive": interactive,
|
||||||
|
"precision": precision,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -375,6 +377,7 @@ class USACOScraper(BaseScraper):
|
||||||
"timeout_ms": 4000,
|
"timeout_ms": 4000,
|
||||||
"memory_mb": 256,
|
"memory_mb": 256,
|
||||||
"interactive": False,
|
"interactive": False,
|
||||||
|
"precision": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
tests = cast(list[TestCase], info["tests"])
|
tests = cast(list[TestCase], info["tests"])
|
||||||
|
|
@ -396,6 +399,7 @@ class USACOScraper(BaseScraper):
|
||||||
"memory_mb": info["memory_mb"],
|
"memory_mb": info["memory_mb"],
|
||||||
"interactive": info["interactive"],
|
"interactive": info["interactive"],
|
||||||
"multi_test": False,
|
"multi_test": False,
|
||||||
|
"precision": info["precision"],
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks = [run_one(cpid) for cpid, _ in problems_raw]
|
tasks = [run_one(cpid) for cpid, _ in problems_raw]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue