-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimetable.py
More file actions
74 lines (58 loc) · 2.09 KB
/
timetable.py
File metadata and controls
74 lines (58 loc) · 2.09 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
74
from datetime import datetime
call_schedule: dict[int, str] = {
1: "08:30 — 09:50",
2: "10:00 — 11:30",
3: "11:40 — 13:10",
4: "13:20 — 14:50",
5: "15:00 — 16:20",
6: "16:30 — 17:50",
7: "18:00 — 19:20"
}
lunch_schedule: dict[int, str] = {
1: "12:10 — 12:30",
2: "12:10 — 12:30",
3: "13:20 — 13:40",
4: "15:30 — 15:50"
}
weekday_names = ["Понедельник", "Вторник", "Среда", "Четверг", "Пятница"]
def get_timetable(
start_lesson_numbers: str, lessons: str
) -> list[tuple[str, list[list[str]]]]:
"""
Args:
start_lesson_numbers: 1 3 0
lessons:
|-------------------------------|
| Психология общения. 41 |
| |
| Физическая культура. Спортзал |
| |
| 0 |
|-------------------------------|
"""
timetable = []
start_lesson_numbers = list(map(int, start_lesson_numbers.split()))
lessons = lessons.replace("\r", "").split("\n\n")
day = datetime.today().day + 1
month = datetime.today().month
for weekday_number, weekday_data in enumerate(lessons):
lesson_number = start_lesson_numbers[weekday_number]
if not lesson_number:
timetable.append((f"{day}.{month} — {weekday_names[weekday_number]}", []))
day += 1
continue
data = []
for lesson in weekday_data.split("\n"):
lesson_name, lesson_room = lesson.split(". ")
data.append([
call_schedule[lesson_number], lesson_name, lesson_room
])
lesson_number += 1
timetable.append((
(
f"{day}.{month} — {weekday_names[weekday_number]} "
f"({lunch_schedule[start_lesson_numbers[weekday_number]]})"
), data
))
day += 1
return timetable