-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecturers.py
More file actions
32 lines (25 loc) · 881 Bytes
/
lecturers.py
File metadata and controls
32 lines (25 loc) · 881 Bytes
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
import json
import os
import random
import data
from constants import MAX_LECTURER_LEVEL, SC_EMOJI
lecturers = []
class Lecturer():
def __init__(self, data_dict):
for key, value in data_dict.items():
setattr(self, key, value) # `key` is a string which is the name of the property being set.
# so if key = 'name', value = 'jeff', the above does self.name = 'jeff'.
def get_trivia_message(self):
return "{}: \"{}\"".format(self.name, random.choice(self.trivia_messages))
def import_lecturers():
global lecturers
lecturers = []
lecturers_data = data.get_lecturers()
for i in lecturers_data:
lecturers.append(Lecturer(i))
def get_by_level(level):
level = min(level, MAX_LECTURER_LEVEL)
for lecturer in lecturers:
if lecturer.level == level:
return lecturer
return None