-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetaData.py
More file actions
56 lines (48 loc) · 1.37 KB
/
metaData.py
File metadata and controls
56 lines (48 loc) · 1.37 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
import json
import os
from datetime import datetime
from typing import List
fileNames = [
'building.min.json',
'campus.min.json',
'course3.min.json',
'courseAttribute.min.json',
'department.min.json',
'description.min.json',
'employee.min.json',
'level.min.json',
'note.min.json',
'prerequisite.min.json',
'requirement.min.json',
'restriction.min.json',
'scheduleType.min.json',
'section.min.json',
'session.min.json',
'subject.min.json',
'tag.min.json',
'title.min.json'
]
if __name__ == '__main__':
# Collect file sizes
fileSizes = {}
for fileName in fileNames:
size = os.path.getsize(fileName)
fileSizes[fileName] = size
# Collect years from sections
years = [-1, -1, -1]
sections: List[dict] = json.load(open('section.json', 'r'))
for section in sections:
year: int = section['year']
semesterId: int = section['semesterId']
if years[semesterId] == -1:
years[semesterId] = year
# Exit when all 3 years has been collected
if -1 not in years:
break
metaData = {
'fileSizes': fileSizes,
'timestamp': datetime.now().timestamp(),
'years': years
}
json.dump(metaData, open('metaData.json', 'w'), indent=4)
json.dump(metaData, open('metaData.min.json', 'w'), separators=(',', ':'))