]> code.communitydata.science - coldcallbot-discord.git/blob - coldcallbot-manual.py
print preferred pronouns in the call list
[coldcallbot-discord.git] / coldcallbot-manual.py
1 #!/usr/bin/env python3
2
3 from coldcall import ColdCall
4 from datetime import datetime
5 from csv import DictReader
6 import json
7
8 current_time = datetime.today()
9 with open("configuration.json") as config_file:
10     config = json.loads(config_file.read())
11
12 ## create the coldcall object
13 cc = ColdCall(record_attendance=False)
14
15 def get_missing(d=current_time):
16     date_string = f'{d.month}/{d.day}/{d.year}'
17     with open(config["optout_file"], 'r') as f:
18         for row in DictReader(f, delimiter="\t"):
19             if row["Date of class session you will be absent"] == date_string:
20                 yield(row[config["unique_name_rowname"]])
21
22 full_names = {}
23 registered_students = []
24 with open(config["roster_file"], 'r') as f:
25     for row in DictReader(f, delimiter=","):
26         student_no = row["StudentNo"].strip()
27         registered_students.append(student_no)
28         full_names[student_no] = f"{row[config['roster_firstname_rowname']]} {row[config['roster_lastname_rowname']]}"
29 # print("Registered:", registered_students) # useful for debug
30
31 # get pronouns
32 with open(config["student_info_file"], 'r') as f:
33     preferred_pronouns = {}
34     for row in DictReader(f, delimiter="\t"):
35         preferred_pronouns[row[config["unique_name_rowname"]]] = row["Preferred pronouns"]
36 print(preferred_pronouns)
37
38 missing_today = [x for x in get_missing(current_time)]
39 # print("Missing Today: ", missing_today)  # useful for debug
40
41 preferred_names = cc.get_preferred_names()
42 # print("Preferred names:", preferred_names)  # useful for debug
43
44 students_present = [s for s in registered_students if s not in missing_today]
45 # print("Students present:", students_present)  # useful for debug
46
47 for i in range(100):
48     selected_student = cc.select_student_from_list(students_present)
49
50     try:
51         preferred_name = preferred_names[selected_student]
52     except KeyError:
53         preferred_name = "[unknown preferred name]"
54
55     if selected_student in preferred_pronouns:
56         pronouns = preferred_pronouns[selected_student]
57     else:
58         pronouns = "[unknown pronouns]"
59     
60     print(f"{i + 1}. {preferred_name} :: {pronouns} :: {full_names[selected_student]} :: {selected_student}")
61
62     cc.record_coldcall(selected_student)
63

Community Data Science Collective || Want to submit a patch?