-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.example.py
40 lines (32 loc) · 1.48 KB
/
main.example.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
import datetime
import logging
from provider.destination.google import GoogleDestinationProvider
from provider.source.google import GoogleSourceProvider
from provider.source.nuist import NUISTSourceProvider
logging.basicConfig(level=logging.INFO)
calendar_id = '[email protected]'
first_school_day = datetime.datetime(2024, 9, 2) # MUST be the first day of semester
source_provider = NUISTSourceProvider(
username="1145141919810",
password="Why do people attend class? Why do people have life?",
first_school_day=first_school_day,
semester="2024-2025-1", # MUST be the semester you want to fetch
headless=True) # Set to false if u wanna see stuff happen
if __name__ == '__main__':
destination_provider = GoogleDestinationProvider(calendar_id)
gs_provider = GoogleSourceProvider(first_school_day=first_school_day, calendar_id=calendar_id)
nuist_course = source_provider.get_courses()
gc_course = gs_provider.get_courses()
addition = nuist_course - gc_course
removal = gc_course - nuist_course
if addition:
print('+', *(e.name for e in addition))
if removal:
print('-', *(e.name for e in removal))
if not addition and not removal:
print("Today there's nothing to do.")
else:
accept = input('Do you accept these changes? (y/N)')
if accept == 'y':
destination_provider.remove_courses(list(removal))
destination_provider.add_courses(list(addition))