-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
77 lines (73 loc) · 1.76 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
69
70
71
72
73
74
75
76
77
import sys
from console_util import *
from Translations import *
def main():
print_welcome_message()
is_open_file1 = False
is_open_file2 = False
tr = Translations()
current_translation_index = 0
while True:
if not is_open_file1:
if open_file(tr, 1) != -1:
is_open_file1 = True
else:
continue
if not is_open_file2:
if open_file(tr, 2) != -1:
is_open_file2 = True
else:
continue
cls()
show_main_help()
print_translation_lines(tr, current_translation_index)
option = input()
if option.lower() == 'u':
add_untranslated(tr)
elif option.lower() == 'n':
if current_translation_index + 10 < len(tr.common_keys):
current_translation_index += 10
else:
print("Not enough lines to show next page. Press Enter.")
press_enter()
elif option.lower() == 'p':
if current_translation_index > 0:
current_translation_index -= 10
else:
print("Not enough lines to show previous page. Press Enter.")
press_enter()
elif option.lower() == 'a':
show_about()
elif option.lower() == 'c':
is_open_file1 = False
is_open_file2 = False
current_translation_index = 0
elif option.lower() == 's':
tr.save_second()
elif option.lower() == 'r':
tr.load_first()
tr.load_second()
elif option.lower() == 'e':
cls()
print("Exit? Any unsaved changes will be lost. [Y to exit]")
i = input()
if i.lower() == 'y':
sys.exit()
elif option == '':
pass
else:
try:
option = int(option)
if 0 <= option <= 9:
if option == 0:
option = 9
else:
option -= 1
edit(tr, tr.common_keys[current_translation_index + option])
else:
raise ValueError()
except ValueError:
print("Please input a valid character.")
press_enter()
if __name__ == "__main__":
main()