summaryrefslogtreecommitdiffstats
path: root/flashcards
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2017-03-02 20:45:53 +0100
committerEduardo Pedroni <e.pedroni91@gmail.com>2017-03-02 20:45:53 +0100
commitb3b6da8ae08a738b5548109e42eaad749d3234e3 (patch)
tree8bda8badab7e9bc5055ff28d6b65f2515efb300b /flashcards
parent8d5537848293196c96dfa5d4b11b658398c2eb14 (diff)
Added colouring for card fronts, card numbering and clean exit
Diffstat (limited to 'flashcards')
-rwxr-xr-xflashcards22
1 files changed, 13 insertions, 9 deletions
diff --git a/flashcards b/flashcards
index 7ba5fa6..e0ba548 100755
--- a/flashcards
+++ b/flashcards
@@ -5,8 +5,7 @@ import sys
from pathlib import Path
from random import shuffle
-'''
-class color:
+class Color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
@@ -18,8 +17,7 @@ class color:
UNDERLINE = '\033[4m'
END = '\033[0m'
-print color.BOLD + 'Hello World !' + color.END
-'''
+#print color.BOLD + 'Hello World !' + color.END
cardRegex = "CARD: "
prefixLength = len(cardRegex)
@@ -63,15 +61,21 @@ def extractCards(f):
cards.append([front.strip(), back.strip()])
return cards
+# Waits for user input and reacts accordingly
+def wait():
+ cmd = input().strip()
+ if cmd.startswith("q") or cmd.startswith("quit") or cmd.startswith("exit"):
+ sys.exit(0)
+
# Loops serving cards to the user until the program is exited
def serveCards(cards):
while True:
- for card in cards:
- print("----------------------------------------------------------------------------")
- print(card[0])
- input()
+ for i, card in enumerate(cards):
+ print("----------------------------------------------------------------------------(" + str(i + 1) + "/" + str(len(cards)) + ")")
+ print(Color.BLUE + Color.BOLD + card[0] + Color.END)
+ wait()
print(card[1])
- input()
+ wait()
def debugCards(cardList):
for c in cardList: