Skip to content

Commit

Permalink
feat: support cf html rank
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
  • Loading branch information
Dup4 committed Jul 23, 2024
1 parent 8a1b083 commit 3ccecb1
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 384 deletions.
784 changes: 401 additions & 383 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pyright = "^1.1.305"
autopep8 = "^2.0.2"
pytest-snapshot = "^0.9.0"
poetry-bumpversion = "^0.3.0"
ipykernel = "^6.29.3"
ipykernel = "^6.29.5"
isort = "^5.13.2"

[build-system]
Expand Down
14 changes: 14 additions & 0 deletions xcpcio_board_spider/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,17 @@ def save_to_disk(data_dir: Path, c: Contest, teams: Teams, runs: Submissions, if
output(data_dir / "config.json", c.get_dict)
output(data_dir / "team.json", teams.get_dict, if_not_exists=if_not_exists)
output(data_dir / "run.json", runs.get_dict, if_not_exists=if_not_exists)


def fetch_json_resp(uri: str):
kTimeoutSecs = 10
if os.path.exists(uri):
with open(uri, 'r') as f:
resp_obj = json.loads(f.read())
else:
resp = requests.get(uri, timeout=kTimeoutSecs)
if resp.status_code != 200:
raise RuntimeError(
f"fetch failed. [status_code={resp.status_code}]")
resp_obj = json.loads(resp.text)
return resp_obj
Empty file.
1 change: 1 addition & 0 deletions xcpcio_board_spider/spider/cf/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .cf import *
27 changes: 27 additions & 0 deletions xcpcio_board_spider/spider/cf/v1/cf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import json
import os
import typing
from pathlib import Path

import requests

from xcpcio_board_spider import (
Contest,
Submission,
Submissions,
Team,
Teams,
constants,
utils,
)


class CF():
kTimeoutSecs = 10

def __init__(self, contest: Contest, fetch_uri: str = None):
self._contest = contest
self._fetch_uri = fetch_uri

self._teams = Teams()
self._runs = Submissions()

0 comments on commit 3ccecb1

Please sign in to comment.