-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
81 lines (65 loc) · 1.82 KB
/
config.py
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
75
76
77
78
79
80
81
import datetime
import json
from pathlib import Path
from pydantic import parse_obj_as, validator, BaseModel
from src.config_base import BaseParserConfig
from src.utils import get_project_root
PROJECT_ROOT = get_project_root()
CONFIG_PATH = Path(__file__).parent / "config.json"
"""Path to config.json file"""
class CoreCoursesConfig(BaseParserConfig):
"""
Config for electives parser from Google Sheets
"""
class Target(BaseModel):
"""
Target model
"""
sheet_name: str
"""Sheet name"""
range: str
"""Range"""
time_columns: list[str]
"""Time columns"""
start_date: datetime.date
"""Datetime start"""
end_date: datetime.date
"""Datetime end"""
class Tag(BaseModel):
"""
Tag model
"""
alias: str
"""Slugged alias of tag"""
type: str
"""Type"""
name: str
"""Short name"""
TARGETS: list[Target]
"""List of targets"""
SEMESTER_TAG: Tag
"""Semester tag"""
SPREADSHEET_ID: str
TEMP_DIR: Path = PROJECT_ROOT / "temp" / "core-courses"
WEEKDAYS = [
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY",
]
ICS_WEEKDAYS = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"]
IGNORED_SUBJECTS: list[str] = [
"Elective courses on Physical Education",
"Elective course on Physical Education",
]
@validator("TEMP_DIR", pre=True)
def ensure_dir(cls, v):
"""Ensure that directory exists"""
v.mkdir(parents=True, exist_ok=True)
return v
with open(CONFIG_PATH, "r") as f:
elective_config_dict = json.load(f)
core_courses_config: CoreCoursesConfig = parse_obj_as(CoreCoursesConfig, elective_config_dict)