Skip to content

Commit

Permalink
Display error message for bad file extension.
Browse files Browse the repository at this point in the history
(The import file dialog will never allow a bad extension, but a user can enter one when launching from the command line.)
  • Loading branch information
dlyongemallo committed Oct 31, 2023
1 parent bfbf963 commit 34f7b67
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zxlive/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ def import_diagram_from_file(file_path: str, selected_filter: str = FileFormat.A
selected_format = next(f for f in FileFormat if f.filter == selected_filter)
if selected_format == FileFormat.All:
ext = file_path.split(".")[-1]
selected_format = next(f for f in FileFormat if f.extension == ext)
try:
selected_format = next(f for f in FileFormat if f.extension == ext)
except StopIteration:
show_error_msg("Failed to import file", f"Couldn't determine filetype: {file_path}.")
return None

# TODO: This would be nicer with match statements (requires python 3.10 though)...
try:
Expand Down

0 comments on commit 34f7b67

Please sign in to comment.