-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec_app.py
More file actions
229 lines (211 loc) · 8.3 KB
/
exec_app.py
File metadata and controls
229 lines (211 loc) · 8.3 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
from util.BS import get_problem_info, get_problem_info_detail, make_file, make_file_all
import os
import sys
program_dir = ""
# example working directory of Windows
# cur_wd = r"C:\Users\gnaro\OneDrive\바탕 화면\Gnaroshi\practice-algorithm-solvedac\With_Levels\Temp"
# example working directory of MacOS
# cur_wd = r"./temp"
cur_wd = r"../practice-algorithm-solvedac/temp"
cur_user = "gnaroshi"
problem_id = 0
problem_title = None
problem_list = []
def exec(cur_wd, cur_user, problem_id, problem_title, problem_list, platform):
while True:
print("1: select working directory")
print("2: select boj problem")
print("3: select multiple boj problem")
print("4: clear selected boj problem")
print("5: make file")
print("6: show selected boj problems")
print("7: show selected boj problems with detail")
print("8: print problems with time taken")
print("9: quit")
print("-" * 60)
n = int(input())
if n == 0:
print(os.getcwd())
elif n == 1:
print("current directory:")
print("##" + os.getcwd() + "##")
while True:
print("1: change directory")
print("2: cancel")
try:
a = int(input())
if a == 1:
print("input new directory:")
t_wd = input()
cur_wd = t_wd
print("changed working directory: ")
print(cur_wd)
os.chdir(cur_wd)
break
elif a == 2:
break
else:
print("undecidable")
except:
print("undecidable")
elif n == 2:
link = input()
problem_id, problem_title = get_problem_info(link)
# TODO make dup file warning
if problem_id == 0 and problem_title == None:
print("-----problem is not sellected-----")
else:
print("problem id: " + str(problem_id))
print("problem title: " + problem_title)
elif n == 3:
print("how many?")
m = int(input())
for i in range(m):
print("input :" + str(i + 1) + ": boj problem link")
while True:
link = input()
try:
problem_id, problem_title = get_problem_info(link)
break
except:
print("please input new address")
# TODO make dup file warning
if problem_id == 0 and problem_title == None:
print("-----problem is not sellected-----")
else:
print("problem id: " + str(problem_id))
print("problem title: " + problem_title)
problem_list.append([problem_id, problem_title])
elif n == 4:
print("problem list cleared")
problem_list = []
problem_id = 0
problem_title = None
elif n == 5:
if len(problem_list) > 1:
print("make all file with c++?")
print("1: yes || 2: no")
while True:
a = int(input())
if a == 1 or a == 2:
break
else:
print("undecidable")
if a == 1:
make_file_all(
problem_list,
program_dir,
platform,
)
elif a == 2:
for temp_problem in problem_list:
print(temp_problem)
make_file(
temp_problem[0],
temp_problem[1],
program_dir,
platform,
)
else:
if problem_id != 0 and problem_title != None:
make_file(problem_id, problem_title, program_dir, platform)
else:
print("there is no selected problems")
elif n == 6:
if len(problem_list) > 1:
print("listed problem size: " + str(len(problem_list)))
cnt = 1
for i, t in problem_list:
print(str(cnt) + "::")
print("problem id: " + str(i))
print("problem title: " + t)
cnt += 1
elif problem_id != 0 and problem_title != None:
print("there is one selected boj problem")
print("problem id: " + str(problem_id))
print("problem title: " + problem_title)
else:
print("none of selected boj problem")
continue
print("want to show [problem id - problem title] form?")
print("1: yes || 2: no")
while True:
try:
a = int(input())
if a == 1:
if len(problem_list) > 1:
for i, t in problem_list:
print(str(i) + " - " + t)
elif problem_id != 0 and problem_title != None:
print("there is one selected boj problem")
print(str(problem_id) + " - " + problem_title)
else:
print("none of selected boj problem")
break
else:
print("undecidable")
except:
print("undecidable")
elif n == 7:
info_detail_attr = [
"titleKo",
"titles",
"problemId",
"isSolvable",
"isPartial",
"level",
"tags",
]
if len(problem_list) > 1:
print("listed problem size: " + str(len(problem_list)))
cnt = 1
for i, t in problem_list:
print(f"{str(cnt):=^30}")
problem_id_detail, problem_info_detail = get_problem_info_detail(
str(i)
)
temp_info_detail = {}
for i in info_detail_attr:
temp_info_detail[i] = problem_info_detail.get(i)
for k in temp_info_detail:
print(k + ": ")
print(temp_info_detail[k])
cnt += 1
elif problem_id != 0 and problem_title != None:
print("there is one selected boj problem")
problem_id_detail, problem_info_detail = get_problem_info_detail(
str(problem_id)
)
temp_info_detail = {}
for i in info_detail_attr:
temp_info_detail[i] = problem_info_detail.get(i)
for k in temp_info_detail:
print(k + ": " + temp_info_detail[k])
else:
print("none of selected boj problem")
continue
elif n == 8:
if len(problem_list) > 1:
print("input times (" + str(len(problem_list)) + ")")
time_list = []
for _ in range(len(problem_list)):
time_list.append(input())
for ti, (i, t) in zip(time_list, problem_list):
print(ti + " - " + str(i) + " - " + t)
elif problem_id != 0 and problem_title != None:
print("there is one selected boj problem")
print(str(problem_id) + " - " + problem_title)
else:
print("none of selected boj problem")
elif n == 9:
print("-" * 60)
print("program terminate")
print("-" * 60)
break
else:
print("undecidable")
print("-" * 60)
if __name__ == "__main__":
program_dir = os.getcwd()
os.chdir(cur_wd)
exec(cur_wd, cur_user, problem_id, problem_title, problem_list, sys.platform)