codeforces/topcode: move to top level and check in ci
This commit is contained in:
parent
657ce08ac8
commit
7b1cec9326
3 changed files with 10 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
from my.config import codeforces as config # type: ignore[attr-defined]
|
||||
|
||||
|
||||
|
@ -8,8 +7,8 @@ import json
|
|||
from typing import NamedTuple, Dict, Iterator
|
||||
|
||||
|
||||
from ..core import get_files, Res, unwrap
|
||||
from ..core.konsume import ignore, wrap
|
||||
from my.core import get_files, Res
|
||||
from my.core.konsume import ignore, wrap
|
||||
|
||||
|
||||
Cid = int
|
||||
|
@ -72,20 +71,16 @@ class Competition(NamedTuple):
|
|||
ignore(json, 'rank', 'oldRating', 'newRating')
|
||||
|
||||
|
||||
def iter_data() -> Iterator[Res[Competition]]:
|
||||
def data() -> Iterator[Res[Competition]]:
|
||||
cmap = get_contests()
|
||||
last = max(get_files(config.export_path, 'codeforces*.json'))
|
||||
|
||||
with wrap(json.loads(last.read_text())) as j:
|
||||
j['status'].ignore()
|
||||
res = j['result'].zoom()
|
||||
j['status'].ignore() # type: ignore[index]
|
||||
res = j['result'].zoom() # type: ignore[index]
|
||||
|
||||
for c in list(res): # TODO maybe we want 'iter' method??
|
||||
ignore(c, 'handle', 'ratingUpdateTimeSeconds')
|
||||
yield from Competition.make(cmap=cmap, json=c)
|
||||
c.consume()
|
||||
# TODO maybe if they are all empty, no need to consume??
|
||||
|
||||
|
||||
def get_data():
|
||||
return list(sorted(iter_data(), key=Competition.when.fget))
|
|
@ -1,16 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
from my.config import topcoder as config # type: ignore[attr-defined]
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from functools import cached_property
|
||||
import json
|
||||
from typing import NamedTuple, Dict, Iterator
|
||||
from typing import NamedTuple, Iterator
|
||||
|
||||
|
||||
from ..core import get_files, Res, unwrap, Json
|
||||
from ..core.error import Res, unwrap
|
||||
from ..core.konsume import zoom, wrap, ignore
|
||||
from my.core import get_files, Res, Json
|
||||
from my.core.konsume import zoom, wrap, ignore
|
||||
|
||||
|
||||
def _get_latest() -> Json:
|
||||
|
@ -54,11 +52,11 @@ class Competition(NamedTuple):
|
|||
)
|
||||
|
||||
|
||||
def iter_data() -> Iterator[Res[Competition]]:
|
||||
def data() -> Iterator[Res[Competition]]:
|
||||
with wrap(_get_latest()) as j:
|
||||
ignore(j, 'id', 'version')
|
||||
|
||||
res = j['result'].zoom()
|
||||
res = j['result'].zoom() # type: ignore[index]
|
||||
ignore(res, 'success', 'status', 'metadata')
|
||||
|
||||
cont = res['content'].zoom()
|
||||
|
@ -77,7 +75,3 @@ def iter_data() -> Iterator[Res[Competition]]:
|
|||
yield from Competition.make(json=c)
|
||||
c.consume()
|
||||
|
||||
|
||||
def get_data():
|
||||
return list(sorted(iter_data(), key=Competition.when.fget))
|
||||
|
2
tox.ini
2
tox.ini
|
@ -169,8 +169,6 @@ commands =
|
|||
|
||||
{envpython} -m mypy --install-types --non-interactive \
|
||||
-p {[testenv]package_name} \
|
||||
--exclude 'my/coding/codeforces.py' \
|
||||
--exclude 'my/coding/topcoder.py' \
|
||||
--txt-report .coverage.mypy-misc \
|
||||
--html-report .coverage.mypy-misc \
|
||||
{posargs}
|
||||
|
|
Loading…
Add table
Reference in a new issue