-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (33 loc) · 815 Bytes
/
main.py
File metadata and controls
38 lines (33 loc) · 815 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
33
34
35
36
37
38
import sys
import os.path
import mode
from ui import *
import config
from anki import Collection as aopen
# Main loop...
def main():
config.init()
x = aopen(config.db_path())
mode.init(x)
while True:
try:
card = mode.make_card()
card.input()
card.output()
if yes_no_p('Save card?'):
card.save(x)
else:
clear_staged_images()
print_subdued('Card dropped!', nl=2)
except EOFError:
clear_staged_images()
print()
except KeyboardInterrupt:
x.close()
sys.exit()
def usage():
print("Usage: {}\n add cards to Anki".format(sys.argv[0]))
if __name__ != '__main__' or len(sys.argv) > 1:
usage()
sys.exit()
main()