-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.py
68 lines (54 loc) · 1.68 KB
/
main.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
60
61
62
63
64
65
66
67
68
# Access point for translating braille to text and vice verse.
import printer, alphaToBraille, brailleToAlpha
from sys import argv
def menu():
print('''
Usage:
main.py <parameter>
main.py <file name> <parameter>
Parameters:
--braille | -b translate braille to text
--text | -t translate text to braille
--help | -h display this screen
--map | -m print translation map
''')
def user_braille():
print("Input Braille: ", end="")
print(brailleToAlpha.translate(input()))
def user_text():
print("Input Text: ", end="")
print(alphaToBraille.translate(input()))
def open_braille(filename):
file = open(filename)
content = file.read()
print(brailleToAlpha.translate(content))
def open_text(filename):
file = open(filename)
content = file.read()
print(alphaToBraille.translate(content))
def argument_handler():
if len(argv) == 1:
menu()
elif len(argv) == 2:
if argv[1] == "--braille" or argv[1] == "-b":
user_braille()
elif argv[1] == "--text" or argv[1] == "-t":
user_text()
elif argv[1] == "--map" or argv[1] == "-m":
printer.all_braille()
else:
menu()
elif len(argv) == 3:
print(argv[0], argv[1], argv[2])
if argv[2] == "--braille" or argv[2] == "-b":
open_braille(argv[1])
elif argv[2] == "--text" or argv[2] == "-t":
open_text(argv[1])
elif argv[2] == "--map" or argv[2] == "-m":
printer.all_braille()
else:
menu()
else:
menu()
if __name__ == "__main__":
argument_handler()