-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
51 lines (46 loc) · 1.41 KB
/
commands.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
# -*- coding: utf-8 -*-
"""
© Copyright 2014. Joon Yang & Jaemin Cheun. All rights reserved.
This is where we keep entry points that we use in setup.py for creating command line commands.
Generally, if it uses argparse, it belongs here.
"""
from __future__ import unicode_literals
from __future__ import print_function
import csv_controller
import argparse
import os
def menu():
"""CSV File as Flashcard Base"""
print("[1] Start Quiz")
print("[2] Add Quiz")
print("[3] Exit")
resp = raw_input(">> ")
if resp == "1":
try:
directory = os.listdir(os.path.join(os.getcwd(),"flashcards"))
for idx, fname in enumerate(directory):
if fname != ".DS_Store":
print(str(idx) + " : " + fname)
print("Type in which flashcard you want to study:")
filename = directory[int(raw_input(">> "))]
print("Tell us how long do you want to study?: (__ min)")
timer = float(raw_input(">> ")) * 60
csv_controller.Reader(filename, timer).start()
except ValueError:
exit(0)
if resp == "2":
print("\n What would you like to name your new flashcards? \n")
newcards = raw_input(">> ")
directory = os.path.join(os.getcwd(), "flashcards/%s.csv" %newcards)
print(directory)
try:
if os.path.exists(directory):
print("Error: a deck with that name already exists!")
exit(0)
else:
csv_controller.Writer(directory).start()
except TypeError:
exit(0)
if resp == "" or '3':
exit(0)
print("="*100)