Skip to content

Commit 57be680

Browse files
committed
fix traversal
1 parent cbbd62c commit 57be680

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

traversal/traversal/traversal.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ def set_initial_values(self):
9898

9999
def path_found(self, i, j):
100100
if self.colored_graph[i][j] == "green":
101-
return rx._x.toast.success(
102-
f"Path found to [{i},{j}]", position="top-center"
103-
)
101+
return rx.toast.success(f"Path found to [{i},{j}]", position="top-center")
104102

105103
def path_not_found(self):
106-
return rx._x.toast.error("No path found", position="top-center")
104+
return rx.toast.error("No path found", position="top-center")
107105

108106
def explore_neighbors(self, i, j, mode=None):
109107
if self.colored_graph[i][j] != "red":

upload/upload/upload.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ async def handle_upload(self, files: List[rx.UploadFile]):
2727
# Iterate through the uploaded files.
2828
for file in files:
2929
upload_data = await file.read()
30-
outfile = Path(rx.get_upload_dir()) / file.name.lstrip("/")
31-
outfile.parent.mkdir(parents=True, exist_ok=True)
32-
outfile.write_bytes(upload_data)
30+
if file.name:
31+
outfile = Path(rx.get_upload_dir()) / file.name.lstrip("/")
32+
outfile.parent.mkdir(parents=True, exist_ok=True)
33+
outfile.write_bytes(upload_data)
34+
else:
35+
# Unlikely to happens but make pyright happy to check for empty file names.
36+
yield rx.toast("File name is empty. Please select a valid file.")
3337

3438
def on_upload_progress(self, prog: dict):
3539
print("Got progress", prog)

0 commit comments

Comments
 (0)