Skip to content

Commit

Permalink
FIX: more linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Nov 18, 2024
1 parent e9fc43d commit be0bd49
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions MethodicConfigurator/frontend_tkinter_directory_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class DirectorySelectionWidgets:

def __init__( # pylint: disable=too-many-arguments
self,
parent,
parent_frame,
parent: tk.Toplevel,
parent_frame: tk.Widget,
initialdir: str,
label_text: str,
autoresize_width: bool,
Expand Down Expand Up @@ -175,7 +175,7 @@ def __init__( # pylint: disable=too-many-arguments
self.local_filesystem = local_filesystem
self.destroy_parent_on_open = destroy_parent_on_open

def on_select_directory(self) -> None:
def on_select_directory(self) -> bool:
# Call the base class method to open the directory selection dialog
if super().on_select_directory():
if "vehicle_templates" in self.directory and not self.local_filesystem.allow_editing_template_files:
Expand All @@ -186,14 +186,14 @@ def on_select_directory(self) -> None:
"as those are used as a template for new vehicles"
),
)
return
return False
self.local_filesystem.vehicle_dir = self.directory

if not self.local_filesystem.vehicle_configuration_files_exist(self.directory):
_filename = self.local_filesystem.vehicle_components_json_filename
error_msg = _("Selected directory must contain files matching \\d\\d_*\\.param and a {_filename} file")
messagebox.showerror(_("Invalid Vehicle Directory Selected"), error_msg.format(**locals()))
return
return False

try:
self.local_filesystem.re_init(self.directory, self.local_filesystem.vehicle_type)
Expand All @@ -207,9 +207,11 @@ def on_select_directory(self) -> None:
LocalFilesystem.store_recently_used_vehicle_dir(self.directory)
if self.destroy_parent_on_open:
self.parent.root.destroy()
return
return True
# No files were found in the selected directory
show_no_param_files_error(self.directory)
return True
return False


class VehicleDirectorySelectionWindow(BaseWindow):
Expand Down

0 comments on commit be0bd49

Please sign in to comment.