Skip to content

Commit 079a73d

Browse files
committed
compleate the basice tui
1 parent d7f6896 commit 079a73d

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

solve.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
# Show the tui for confirm the data and choose the language to solve the problem
6666
data = Data(title, level, problem_path)
6767
tui.confirm_data(data)
68-
print(data)
69-
exit(0)
7068

7169
# Download the images if there are any
7270
for img in discription.find_all("img"):
@@ -102,23 +100,27 @@
102100
f.write("## There is no note for this problem yet ¯⁠⁠⁠\(⁠ツ⁠)⁠⁠/⁠¯")
103101

104102
# Create the solution project for each language
105-
for lang in data.solve_with:
106-
lang_path = os.path.join(data.problem_path, lang)
107-
if not os.path.exists(lang_path):
108-
os.mkdir(lang_path)
109-
match lang:
110-
case "python" | "py":
111-
create_python_project(lang_path)
112-
case "java":
113-
create_java_project(lang_path)
114-
case "c++" | "cpp":
115-
create_cpp_project(lang_path)
116-
case "c":
117-
create_c_project(lang_path)
118-
case "rust":
119-
create_rust_project(lang_path)
120-
case "go":
121-
create_go_project(lang_path)
122-
case _: # If other language, do nothing
123-
pass
103+
if data.solve_with:
104+
print("Creating the solution projects...")
105+
for lang in data.solve_with:
106+
lang_path = os.path.join(data.problem_path, lang)
107+
if not os.path.exists(lang_path):
108+
os.mkdir(lang_path)
109+
match lang:
110+
case "python" | "py":
111+
create_python_project(lang_path)
112+
case "java":
113+
create_java_project(lang_path)
114+
case "c++" | "cpp":
115+
create_cpp_project(lang_path)
116+
case "c":
117+
create_c_project(lang_path)
118+
case "rust":
119+
create_rust_project(lang_path)
120+
case "go":
121+
create_go_project(lang_path)
122+
case _: # If other language, do nothing
123+
pass
124+
else:
125+
print("No language to solve the problem with, skipping the solution projects creation...")
124126

utils/pytermgui_tui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ def parse_data(manager: ptg.WindowManager, window: ptg.Window, data: Data) -> No
7272
elif widget.prompt == "Base path:":
7373
data.problem_path = widget.value
7474
elif widget.prompt == "Solve with:":
75-
data.solve_with = [str(s).strip() for s in widget.value.split(",")]
75+
# Remove the last comma if exists
76+
value = str(widget.value).strip()
77+
if value.endswith(","):
78+
value = value[:-1]
79+
data.solve_with = [s.strip() for s in value.split(",")]
7680
manager.stop()
7781

7882
def confirm_data(data: Data) -> None:

0 commit comments

Comments
 (0)