-
Notifications
You must be signed in to change notification settings - Fork 0
/
rungenerator.py
60 lines (46 loc) · 1.45 KB
/
rungenerator.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
"""Run the generator interactively.
"""
from generator.generator import Generator
import pdb
def get_coerced_input(message, coerce):
"""Get input that coerces into a certain data type.
"""
while True:
text = input(message + " ")
try:
return coerce(text)
except ValueError:
continue
def get_input_list(message):
input_list = []
while True:
text = input(message + " " + str(len(input_list) + 1) + ": ")
if str(text):
input_list.append(text)
else:
return input_list
def generate_interactively():
print("Welcome to the temp unit generator.")
print()
iterations = get_coerced_input("How many total units will the class go "
"through?", int)
print()
print("Enter the names of the students, hitting enter after every name.")
print("Press enter without writing anything to stop adding students.")
print()
student_names = get_input_list("Student")
print()
number_of_units = get_coerced_input("How many different units are there?",
int)
print()
print("Okay, generating class.")
print()
generator = Generator(iterations, student_names, number_of_units)
generator.assort_students()
print("Here's how to assign the students:")
print()
generator.print_classes()
print()
print("You should save this list for future use.")
if __name__ == "__main__":
generate_interactively()