orangehack 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orangehack/__init__.py +15 -0
- orangehack/__main__.py +3 -0
- orangehack/client.py +239 -0
- orangehack/commands/__init__.py +1 -0
- orangehack/commands/api.py +347 -0
- orangehack/commands/attempts.py +253 -0
- orangehack/commands/auth.py +224 -0
- orangehack/commands/competitions.py +215 -0
- orangehack/commands/download.py +145 -0
- orangehack/commands/leaderboard.py +114 -0
- orangehack/commands/submit.py +372 -0
- orangehack/config.py +221 -0
- orangehack/errors.py +109 -0
- orangehack/main.py +98 -0
- orangehack/output.py +105 -0
- orangehack/resolve.py +172 -0
- orangehack/session.py +127 -0
- orangehack/transfer.py +442 -0
- orangehack/version_check.py +104 -0
- orangehack-0.1.0.dist-info/METADATA +145 -0
- orangehack-0.1.0.dist-info/RECORD +23 -0
- orangehack-0.1.0.dist-info/WHEEL +4 -0
- orangehack-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""`competitions`, `cases`, `deliverables`: what a person takes part in and what to hand in."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Any
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from .. import resolve
|
|
10
|
+
from ..output import table
|
|
11
|
+
from ..session import JsonOpt, Session, execute
|
|
12
|
+
|
|
13
|
+
WINDOW = {"open": "открыт", "upcoming": "ещё не открыт", "closed": "закрыт", "none": "без срока"}
|
|
14
|
+
TYPES = {"file": "файл", "archive": "архив", "url": "ссылка", "form": "форма", "text": "текст"}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def when(value: Any) -> str:
|
|
18
|
+
return str(value).replace("T", " ")[:16] if value else "—"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def competitions(
|
|
22
|
+
ctx: typer.Context,
|
|
23
|
+
all_: Annotated[bool, typer.Option("--all", help="Весь каталог, а не только мои.")] = False,
|
|
24
|
+
json_: JsonOpt = False,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Мои соревнования (или весь каталог с --all)."""
|
|
27
|
+
|
|
28
|
+
def body(s: Session) -> None:
|
|
29
|
+
if all_:
|
|
30
|
+
found = s.client.get("/api/v1/competitions/catalog", params={"limit": 100}) or {}
|
|
31
|
+
items = [
|
|
32
|
+
{
|
|
33
|
+
"id": i["id"],
|
|
34
|
+
"address": f"{i['organization']['slug']}/{i['slug']}",
|
|
35
|
+
"title": i["title"],
|
|
36
|
+
"status": i.get("status", ""),
|
|
37
|
+
"type": i.get("type", ""),
|
|
38
|
+
}
|
|
39
|
+
for i in found.get("items", [])
|
|
40
|
+
if i.get("source", "platform") == "platform"
|
|
41
|
+
]
|
|
42
|
+
else:
|
|
43
|
+
mine = (
|
|
44
|
+
s.signed_in().get(
|
|
45
|
+
"/api/v1/competitions/catalog/mine", params={"group": "participation"}
|
|
46
|
+
)
|
|
47
|
+
or []
|
|
48
|
+
)
|
|
49
|
+
items = [
|
|
50
|
+
{
|
|
51
|
+
"id": m["competition"]["id"],
|
|
52
|
+
"address": f"{m['competition']['organization']['slug']}/{m['competition']['slug']}",
|
|
53
|
+
"title": m["competition"]["title"],
|
|
54
|
+
"status": m.get("state", ""),
|
|
55
|
+
}
|
|
56
|
+
for m in mine
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
def human() -> None:
|
|
60
|
+
if not items:
|
|
61
|
+
s.output.say("Соревнований нет." if all_ else "Вы пока ни в чём не участвуете.")
|
|
62
|
+
return
|
|
63
|
+
s.output.say(
|
|
64
|
+
table(
|
|
65
|
+
["Адрес", "Название", "Статус"],
|
|
66
|
+
[[i["address"], i["title"], i["status"]] for i in items],
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
s.output.result({"competitions": items}, human)
|
|
71
|
+
|
|
72
|
+
execute(ctx, json_, body)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def overview_of(s: Session, competition: resolve.Competition) -> dict[str, Any]:
|
|
76
|
+
data: dict[str, Any] = s.signed_in().get(
|
|
77
|
+
f"/api/v1/deliverables/competitions/{competition.id}/overview"
|
|
78
|
+
)
|
|
79
|
+
return data
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def case_keys(s: Session, competition: resolve.Competition) -> dict[str, str]:
|
|
83
|
+
"""case id -> key, from the leaderboard's list of cases (the overview names cases by title)."""
|
|
84
|
+
try:
|
|
85
|
+
rows = s.client.get(f"/api/v1/leaderboard/competitions/{competition.id}/cases") or []
|
|
86
|
+
except Exception:
|
|
87
|
+
return {}
|
|
88
|
+
return {str(r["case_id"]): str(r["key"]) for r in rows}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def cases(
|
|
92
|
+
ctx: typer.Context,
|
|
93
|
+
competition: Annotated[str, typer.Argument(help="Адрес (организация/соревнование) или id.")],
|
|
94
|
+
json_: JsonOpt = False,
|
|
95
|
+
) -> None:
|
|
96
|
+
"""Этапы и кейсы соревнования, их окна и чего не хватает."""
|
|
97
|
+
|
|
98
|
+
def body(s: Session) -> None:
|
|
99
|
+
target = resolve.competition(s.signed_in(), competition)
|
|
100
|
+
overview = overview_of(s, target)
|
|
101
|
+
keys = case_keys(s, target)
|
|
102
|
+
groups = [
|
|
103
|
+
{
|
|
104
|
+
"id": g["id"],
|
|
105
|
+
"kind": g["kind"],
|
|
106
|
+
"key": keys.get(str(g["id"]), ""),
|
|
107
|
+
"title": g["title"],
|
|
108
|
+
"stage": g.get("stage_title", ""),
|
|
109
|
+
"deliverables": [d["key"] for d in g.get("items", [])],
|
|
110
|
+
}
|
|
111
|
+
for g in overview.get("groups", [])
|
|
112
|
+
]
|
|
113
|
+
missing = overview.get("missing", [])
|
|
114
|
+
|
|
115
|
+
def human() -> None:
|
|
116
|
+
s.output.say(f"{target.title} ({target.address})")
|
|
117
|
+
s.output.say(
|
|
118
|
+
table(
|
|
119
|
+
["Ключ", "Кейс или этап", "Этап", "Сдачи"],
|
|
120
|
+
[
|
|
121
|
+
[
|
|
122
|
+
g["key"] or "—",
|
|
123
|
+
g["title"],
|
|
124
|
+
g["stage"] or "—",
|
|
125
|
+
", ".join(g["deliverables"]) or "—",
|
|
126
|
+
]
|
|
127
|
+
for g in groups
|
|
128
|
+
],
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
if missing:
|
|
132
|
+
s.output.say("")
|
|
133
|
+
s.output.say("Ещё не сдано:")
|
|
134
|
+
for m in missing:
|
|
135
|
+
s.output.say(
|
|
136
|
+
f" {m['title']} ({m['owner_title']}) — до {when(m.get('closes_at'))}"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
s.output.result(
|
|
140
|
+
{"competition": target.__dict__, "groups": groups, "missing": missing}, human
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
execute(ctx, json_, body)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def deliverables(
|
|
147
|
+
ctx: typer.Context,
|
|
148
|
+
competition: Annotated[str, typer.Argument(help="Адрес (организация/соревнование) или id.")],
|
|
149
|
+
case: Annotated[str | None, typer.Option("--case", help="Ключ или название кейса.")] = None,
|
|
150
|
+
json_: JsonOpt = False,
|
|
151
|
+
) -> None:
|
|
152
|
+
"""Что сдавать: тип, срок, сколько версий осталось."""
|
|
153
|
+
|
|
154
|
+
def body(s: Session) -> None:
|
|
155
|
+
target = resolve.competition(s.signed_in(), competition)
|
|
156
|
+
overview = overview_of(s, target)
|
|
157
|
+
items = resolve.narrow(
|
|
158
|
+
resolve.deliverables(overview),
|
|
159
|
+
case=case,
|
|
160
|
+
case_keys=case_keys(s, target) if case else None,
|
|
161
|
+
)
|
|
162
|
+
rows = []
|
|
163
|
+
for d in items:
|
|
164
|
+
detail = s.client.get(
|
|
165
|
+
f"/api/v1/deliverables/competitions/{target.id}/deliverables/{d.id}"
|
|
166
|
+
)
|
|
167
|
+
limit = detail.get("max_versions")
|
|
168
|
+
used = d.card.get("accepted_versions", 0)
|
|
169
|
+
rows.append(
|
|
170
|
+
{
|
|
171
|
+
"id": d.id,
|
|
172
|
+
"key": d.key,
|
|
173
|
+
"title": d.title,
|
|
174
|
+
"case": d.group_title,
|
|
175
|
+
"type": d.type,
|
|
176
|
+
"window": d.window.get("state"),
|
|
177
|
+
"closes_at": d.window.get("closes_at"),
|
|
178
|
+
"accepted_versions": used,
|
|
179
|
+
"max_versions": limit,
|
|
180
|
+
"versions_left": None if limit is None else max(limit - used, 0),
|
|
181
|
+
"max_mb": detail.get("max_mb"),
|
|
182
|
+
"formats": detail.get("formats", []),
|
|
183
|
+
"handed_in": d.card.get("handed_in", False),
|
|
184
|
+
"blocked": d.blocked,
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
def human() -> None:
|
|
189
|
+
if not rows:
|
|
190
|
+
s.output.say("Сдавать пока нечего.")
|
|
191
|
+
return
|
|
192
|
+
s.output.say(
|
|
193
|
+
table(
|
|
194
|
+
["Ключ", "Сдача", "Кейс", "Тип", "Приём", "До", "Версий осталось"],
|
|
195
|
+
[
|
|
196
|
+
[
|
|
197
|
+
r["key"],
|
|
198
|
+
r["title"],
|
|
199
|
+
r["case"],
|
|
200
|
+
TYPES.get(r["type"], r["type"]),
|
|
201
|
+
WINDOW.get(r["window"] or "none", r["window"]),
|
|
202
|
+
when(r["closes_at"]),
|
|
203
|
+
"без лимита" if r["versions_left"] is None else r["versions_left"],
|
|
204
|
+
]
|
|
205
|
+
for r in rows
|
|
206
|
+
],
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
for r in rows:
|
|
210
|
+
if r["blocked"]:
|
|
211
|
+
s.output.say(f" {r['key']}: {r['blocked'].get('message', '')}")
|
|
212
|
+
|
|
213
|
+
s.output.result({"competition": target.__dict__, "deliverables": rows}, human)
|
|
214
|
+
|
|
215
|
+
execute(ctx, json_, body)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""`download`: case materials and the person's own handed-in files, resumable."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Annotated, Any
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
|
|
10
|
+
from .. import resolve, transfer
|
|
11
|
+
from ..errors import CliError, Exit
|
|
12
|
+
from ..session import JsonOpt, Session, execute
|
|
13
|
+
from .competitions import overview_of
|
|
14
|
+
|
|
15
|
+
_safe = transfer.safe_name
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _fetch(
|
|
19
|
+
s: Session,
|
|
20
|
+
object_id: str,
|
|
21
|
+
directory: Path,
|
|
22
|
+
fallback: str,
|
|
23
|
+
taken: set[Path],
|
|
24
|
+
overwrite: bool,
|
|
25
|
+
) -> Path:
|
|
26
|
+
def reopen() -> transfer.Opened:
|
|
27
|
+
opened = s.client.get(f"/api/v1/files/{object_id}/open")
|
|
28
|
+
return transfer.Opened(url=str(opened["url"]))
|
|
29
|
+
|
|
30
|
+
def progress(done: int, total: int) -> None:
|
|
31
|
+
share = f"{int(done * 100 / total)}%" if total else f"{done / 1024 / 1024:.1f} МБ"
|
|
32
|
+
s.output.progress(f"Скачивание {fallback}: {share}")
|
|
33
|
+
|
|
34
|
+
kept: list[tuple[Path, Path]] = []
|
|
35
|
+
path = transfer.download(
|
|
36
|
+
s.client.storage,
|
|
37
|
+
reopen,
|
|
38
|
+
directory,
|
|
39
|
+
object_id,
|
|
40
|
+
_safe(fallback),
|
|
41
|
+
progress=progress,
|
|
42
|
+
sleep=s.sleep,
|
|
43
|
+
taken=taken,
|
|
44
|
+
overwrite=overwrite,
|
|
45
|
+
kept_aside=lambda wanted, saved: kept.append((wanted, saved)),
|
|
46
|
+
)
|
|
47
|
+
s.output.progress_done()
|
|
48
|
+
for wanted, saved in kept:
|
|
49
|
+
s.output.note(
|
|
50
|
+
f"{wanted} уже есть и отличается: новый файл сохранён как {saved.name} "
|
|
51
|
+
"(--overwrite — заменить)."
|
|
52
|
+
)
|
|
53
|
+
return path
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _materials(
|
|
57
|
+
s: Session, target: resolve.Competition, case: str | None
|
|
58
|
+
) -> tuple[str, list[dict[str, Any]]]:
|
|
59
|
+
page = s.client.get(f"/api/v1/competitions/public/{target.org}/{target.slug}")
|
|
60
|
+
cases = [c for stage in page.get("stages", []) for c in stage.get("cases", [])]
|
|
61
|
+
if case:
|
|
62
|
+
needle = case.casefold()
|
|
63
|
+
cases = [c for c in cases if needle in (c["key"].casefold(), c["title"].casefold())] or [
|
|
64
|
+
c for c in cases if c["title"].casefold().startswith(needle)
|
|
65
|
+
]
|
|
66
|
+
if len(cases) != 1:
|
|
67
|
+
listed = "\n".join(f" {c['key']} {c['title']}" for c in cases)
|
|
68
|
+
raise CliError(
|
|
69
|
+
Exit.USAGE,
|
|
70
|
+
"Выберите кейс:\n" + listed if cases else "Кейс не найден.",
|
|
71
|
+
"orangehack download <соревнование> --case <ключ>",
|
|
72
|
+
code="ambiguous",
|
|
73
|
+
)
|
|
74
|
+
key = cases[0]["key"]
|
|
75
|
+
detail = s.client.get(f"/api/v1/competitions/public/{target.org}/{target.slug}/cases/{key}")
|
|
76
|
+
return key, list(detail.get("materials", []))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def download(
|
|
80
|
+
ctx: typer.Context,
|
|
81
|
+
competition: Annotated[str, typer.Argument(help="Адрес (организация/соревнование) или id.")],
|
|
82
|
+
case: Annotated[str | None, typer.Option("--case", help="Ключ или название кейса.")] = None,
|
|
83
|
+
mine: Annotated[
|
|
84
|
+
bool, typer.Option("--mine", help="Мои сданные файлы (текущие версии), а не материалы.")
|
|
85
|
+
] = False,
|
|
86
|
+
to: Annotated[Path | None, typer.Option("--to", help="Куда сохранить (папка).")] = None,
|
|
87
|
+
overwrite: Annotated[
|
|
88
|
+
bool,
|
|
89
|
+
typer.Option("--overwrite", help="Заменять уже скачанные файлы, даже если они другие."),
|
|
90
|
+
] = False,
|
|
91
|
+
json_: JsonOpt = False,
|
|
92
|
+
) -> None:
|
|
93
|
+
"""Скачать материалы кейса или свои сданные файлы. Обрыв — запустите снова, докачается."""
|
|
94
|
+
|
|
95
|
+
def body(s: Session) -> None:
|
|
96
|
+
target = resolve.competition(s.signed_in(), competition)
|
|
97
|
+
saved: list[dict[str, Any]] = []
|
|
98
|
+
taken: set[Path] = set() # two files with one name are saved side by side
|
|
99
|
+
if mine:
|
|
100
|
+
directory = to or Path(target.slug)
|
|
101
|
+
items = resolve.narrow(resolve.deliverables(overview_of(s, target)), case=case)
|
|
102
|
+
for d in items:
|
|
103
|
+
detail = s.client.get(
|
|
104
|
+
f"/api/v1/deliverables/competitions/{target.id}/deliverables/{d.id}"
|
|
105
|
+
)
|
|
106
|
+
for version in detail.get("versions", []):
|
|
107
|
+
payload = version.get("payload") or {}
|
|
108
|
+
if version.get("is_current") and payload.get("file_id"):
|
|
109
|
+
name = payload.get("filename") or f"{d.key}-v{version.get('version')}"
|
|
110
|
+
path = _fetch(
|
|
111
|
+
s,
|
|
112
|
+
str(payload["file_id"]),
|
|
113
|
+
directory / _safe(d.key),
|
|
114
|
+
str(name),
|
|
115
|
+
taken,
|
|
116
|
+
overwrite,
|
|
117
|
+
)
|
|
118
|
+
saved.append(
|
|
119
|
+
{"deliverable": d.key, "path": str(path), "size": path.stat().st_size}
|
|
120
|
+
)
|
|
121
|
+
else:
|
|
122
|
+
key, materials = _materials(s, target, case)
|
|
123
|
+
directory = to or Path(_safe(key))
|
|
124
|
+
for material in materials:
|
|
125
|
+
path = _fetch(
|
|
126
|
+
s,
|
|
127
|
+
str(material["object_id"]),
|
|
128
|
+
directory,
|
|
129
|
+
str(material.get("title") or "material"),
|
|
130
|
+
taken,
|
|
131
|
+
overwrite,
|
|
132
|
+
)
|
|
133
|
+
saved.append(
|
|
134
|
+
{"title": material.get("title"), "path": str(path), "size": path.stat().st_size}
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
def human() -> None:
|
|
138
|
+
if not saved:
|
|
139
|
+
s.output.say("Скачивать нечего.")
|
|
140
|
+
for item in saved:
|
|
141
|
+
s.output.say(f"{item['path']} ({item['size'] / 1024 / 1024:.1f} МБ)")
|
|
142
|
+
|
|
143
|
+
s.output.result({"files": saved}, human)
|
|
144
|
+
|
|
145
|
+
execute(ctx, json_, body)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""`leaderboard`: the boards a person may see, as the site shows them."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Any
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from .. import resolve
|
|
10
|
+
from ..errors import CliError, Exit
|
|
11
|
+
from ..output import table
|
|
12
|
+
from ..session import JsonOpt, Session, execute
|
|
13
|
+
|
|
14
|
+
CLOSED = {"everyone", "participants", "hidden"}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _case(s: Session, target: resolve.Competition, case: str | None) -> dict[str, Any]:
|
|
18
|
+
cases = s.client.get(f"/api/v1/leaderboard/competitions/{target.id}/cases") or []
|
|
19
|
+
if not cases:
|
|
20
|
+
raise CliError(Exit.USAGE, "У этого соревнования нет таблиц.", code="no_boards")
|
|
21
|
+
if case is None:
|
|
22
|
+
if len(cases) == 1:
|
|
23
|
+
return dict(cases[0])
|
|
24
|
+
listed = "\n".join(f" {c['key']} {c['title']}" for c in cases)
|
|
25
|
+
raise CliError(
|
|
26
|
+
Exit.USAGE,
|
|
27
|
+
f"Таблиц несколько, выберите кейс:\n{listed}",
|
|
28
|
+
"orangehack leaderboard <соревнование> --case <ключ> (или --overall)",
|
|
29
|
+
code="ambiguous",
|
|
30
|
+
extra={"candidates": cases},
|
|
31
|
+
)
|
|
32
|
+
needle = case.casefold()
|
|
33
|
+
exact = [c for c in cases if needle in (c["key"].casefold(), c["title"].casefold())]
|
|
34
|
+
found = exact or [c for c in cases if c["title"].casefold().startswith(needle)]
|
|
35
|
+
if len(found) != 1:
|
|
36
|
+
raise CliError(Exit.USAGE, f"Кейс «{case}» не найден или неоднозначен.", code="ambiguous")
|
|
37
|
+
return dict(found[0])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def leaderboard(
|
|
41
|
+
ctx: typer.Context,
|
|
42
|
+
competition: Annotated[str, typer.Argument(help="Адрес (организация/соревнование) или id.")],
|
|
43
|
+
case: Annotated[str | None, typer.Option("--case", help="Ключ или название кейса.")] = None,
|
|
44
|
+
overall: Annotated[bool, typer.Option("--overall", help="Общий зачёт по кейсам.")] = False,
|
|
45
|
+
limit: Annotated[int, typer.Option("--limit", help="Сколько строк показать.")] = 20,
|
|
46
|
+
json_: JsonOpt = False,
|
|
47
|
+
) -> None:
|
|
48
|
+
"""Таблица кейса (или общий зачёт) и моё место."""
|
|
49
|
+
|
|
50
|
+
def body(s: Session) -> None:
|
|
51
|
+
target = resolve.competition(s.signed_in(), competition)
|
|
52
|
+
if overall:
|
|
53
|
+
data = s.client.get(f"/api/v1/leaderboard/competitions/{target.id}/overall")
|
|
54
|
+
|
|
55
|
+
def human_overall() -> None:
|
|
56
|
+
rows = data.get("rows", [])[:limit]
|
|
57
|
+
if not rows:
|
|
58
|
+
s.output.say("Общий зачёт пока пуст.")
|
|
59
|
+
for note in data.get("notes", []):
|
|
60
|
+
s.output.say(note)
|
|
61
|
+
s.output.say(
|
|
62
|
+
table(
|
|
63
|
+
["Место", "Участник", "Сумма"],
|
|
64
|
+
[[r["rank"], r["name"], r["total"]] for r in rows],
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
s.output.result({"competition": target.__dict__, "overall": data}, human_overall)
|
|
69
|
+
return
|
|
70
|
+
chosen = _case(s, target, case)
|
|
71
|
+
board = s.client.get(
|
|
72
|
+
f"/api/v1/leaderboard/cases/{chosen['case_id']}",
|
|
73
|
+
params={"limit": limit, "around_own": "true"},
|
|
74
|
+
)
|
|
75
|
+
closed = not board.get("shown", True) or board.get("hidden_for") in CLOSED
|
|
76
|
+
if closed:
|
|
77
|
+
board = {**board, "rows": [], "neighbours": []}
|
|
78
|
+
|
|
79
|
+
def human() -> None:
|
|
80
|
+
s.output.say(f"{chosen['title']} — {target.title}")
|
|
81
|
+
if closed:
|
|
82
|
+
s.output.say("Таблица закрыта для участников.")
|
|
83
|
+
return
|
|
84
|
+
if board.get("frozen") or (board.get("freeze") or {}).get("frozen"):
|
|
85
|
+
s.output.say("Таблица заморожена: новые оценки откроются после финала.")
|
|
86
|
+
rows = board.get("rows", [])
|
|
87
|
+
if not rows:
|
|
88
|
+
s.output.say("В таблице пока никого.")
|
|
89
|
+
else:
|
|
90
|
+
s.output.say(
|
|
91
|
+
table(
|
|
92
|
+
["Место", "Участник", "Оценка"],
|
|
93
|
+
[
|
|
94
|
+
[
|
|
95
|
+
r.get("rank") or "—",
|
|
96
|
+
("→ " if r.get("own") else "") + r["name"],
|
|
97
|
+
r.get("value") or "—",
|
|
98
|
+
]
|
|
99
|
+
for r in rows
|
|
100
|
+
],
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
own = board.get("own")
|
|
104
|
+
if own and not any(r.get("own") for r in rows):
|
|
105
|
+
s.output.say(
|
|
106
|
+
f"Ваше место: {own.get('rank') or '—'} из {board.get('total')}, оценка {own.get('value') or '—'}"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
s.output.result(
|
|
110
|
+
{"competition": target.__dict__, "case": chosen, "closed": closed, "board": board},
|
|
111
|
+
human,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
execute(ctx, json_, body)
|