Repository navigation
Expand file tree
/
Copy pathmodels.py
More file actions
73 lines (55 loc) · 1.48 KB
/
Copy pathmodels.py
File metadata and controls
73 lines (55 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Shared data types; saved IDs are part of the compatibility contract."""
from __future__ import annotations
import argparse
import subprocess
from pathlib import Path
from typing import Literal, TypedDict, final
class LessonNote(TypedDict, total=False):
note: str
class Lesson(LessonNote):
id: str
key: str
title: str
url: str
class Chapter(TypedDict):
id: str
title: str
group: str
lessons: list[Lesson]
class ViewState(TypedDict):
group: str
chapter: str | None
index: int
stream: bool
class StateData(TypedDict):
version: int
completed: list[str]
notes: dict[str, str]
focus: str | None
name: str
view: ViewState
@final
class Options(argparse.Namespace):
"""Typed command-line values; argparse fills these from the declared flags."""
name: str | None = None
state: Path
demo: bool = False
stream: bool = False
ascii: bool = False
color: str = "auto"
summary: bool = False
state_path: bool = False
uninstall: bool = False
def __init__(self, state: Path) -> None:
super().__init__()
self.state = state
Node = Lesson | Chapter
Modal = (
tuple[Literal["notes", "notes_confirm"], str, str, str]
| tuple[Literal["bulk"], str]
| tuple[Literal["search"]]
| tuple[Literal["help"]]
)
JsonValue = bool | int | float | str | None | list["JsonValue"] | dict[str, "JsonValue"]
NoteRow = tuple[int, int, str]
BrowserJob = tuple[subprocess.Popen[bytes], str]