-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventdata.py
66 lines (50 loc) · 1.64 KB
/
eventdata.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
import json
# matches classes from ems to the merged database i made
# for some reason, results in different counts of matched classes every time i run it
with open('events.json') as f:
events = json.load(f)
y,m,d = events['day']
del events['day']
import datetime
today = datetime.date(year = y, month = m, day = d)
import itertools as it
cevents = [e for e in events['events'] if e['owner'] == 'Registrar']
import re
eclasses = []
for i,c in enumerate(cevents):
dep,num,sec,name = re.fullmatch(r'(?:(.{3})-(\d{4}(?:C|L|))-(\d{2}(?:HB)?) )?(.*)', c['name']).groups()
name = name.replace('&', '&')
eclasses.append({
'id': i,
'code': f'{dep} {num}' if dep is not None else '',
'section': sec,
'name': name,
'room': c['room'],
'start': c['start'],
'end': c['end'],
})
day = 'MTWRF__'[today.weekday()]
import polydata
pclasses = [c for c in polydata.mergedclasses if day in (c['days'] or '')]
ecodes = sorted([c['code'] for c in eclasses])
pcodes = sorted([c['code'] for c in pclasses])
print(ecodes)
print(pcodes)
print(sorted(set(ecodes) - set(pcodes)))
print(sorted(set(pcodes) - set(ecodes)))
pairs = []
for (ie,ec),(ip,pc) in it.product(enumerate(eclasses), enumerate(pclasses)):
if ec['code'] != pc['code']:
continue
if ec['section'] != pc['section']:
continue
if ec['start'] != pc['start']:
continue
if ec['end'] != pc['end']:
continue
if ec['room'] != pc['room']:
print(ec['room'], '!=', pc['room'], '!!!!!')
pairs.append((ie, ip))
assert len(pairs) == len([p[0] for p in pairs]), 'doubled class event'
assert len(pairs) == len([p[0] for p in pairs]), 'doubled poly class (cams / office)'
print(len(pairs), 'matched classes')