-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
120 lines (78 loc) · 2.74 KB
/
__init__.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from __future__ import annotations
from datetime import datetime, timedelta
from typing import Any
from attrs import Factory, define, field
# =========== CUSTOM CONVERTORS ============
def _timedelta_convertor(value: str) -> timedelta:
parsed = datetime.strptime(value, "%H%M")
return timedelta(hours=parsed.hour, minutes=parsed.minute)
def _identity_convertor(value: Any) -> Any:
return value
# =========== CONFIG DEFINITIONS ===========
# -------- SOURCES CONFIG --------
@define(kw_only=True)
class ConfigSourcesTimetable:
url: str
@define(kw_only=True)
class ConfigSourcesEClassroom:
token: str
webserviceUrl: str
pluginFileWebserviceUrl: str
pluginFileNormalUrl: str
course: int
@define(kw_only=True)
class ConfigSourcesMenu:
url: str
@define(kw_only=True)
class ConfigSourcesSolsis:
url: str
serverName: str
apiKey: str
@define(kw_only=True)
class ConfigSources:
timetable: ConfigSourcesTimetable
eclassroom: ConfigSourcesEClassroom
menu: ConfigSourcesMenu
solsis: ConfigSourcesSolsis
# --------- URLS CONFIG ---------
@define(kw_only=True)
class ConfigURLs:
website: str
api: str
# -------- SENTRY CONFIG ---------
@define(kw_only=True)
class ConfigSentryTracesSampleRate:
commands: float | int | bool = field(default=1.0, converter=_identity_convertor)
requests: float | int | bool = field(default=1.0, converter=_identity_convertor)
other: float | int | bool = field(default=1.0, converter=_identity_convertor)
@define(kw_only=True)
class ConfigSentryProfilerSampleRate:
commands: float | int | bool = field(default=False, converter=_identity_convertor)
requests: float | int | bool = field(default=False, converter=_identity_convertor)
other: float | int | bool = field(default=False, converter=_identity_convertor)
@define(kw_only=True)
class ConfigSentry:
dsn: str
enabled: bool = True
collectIPs: bool = False
releasePrefix: str = ""
releaseSuffix: str = ""
maxBreadcrumbs: int = 100
tracesSampleRate: ConfigSentryTracesSampleRate = Factory(ConfigSentryTracesSampleRate)
profilerSampleRate: ConfigSentryProfilerSampleRate = Factory(ConfigSentryProfilerSampleRate)
# ------ LESSON TIME CONFIG ------
@define(kw_only=True)
class ConfigLessonTime:
name: str
start: timedelta = field(converter=_timedelta_convertor)
end: timedelta = field(converter=_timedelta_convertor)
# --------- MAIN CONFIG ----------
@define(kw_only=True)
class Config:
sources: ConfigSources
urls: ConfigURLs
database: str
cors: list[str] = Factory(list)
sentry: ConfigSentry | None = None
logging: dict | str | None = field(default=None, converter=_identity_convertor)
lessonTimes: list[ConfigLessonTime]