Commit d2a35dc5 authored by Roman Alifanov's avatar Roman Alifanov

improve the readability of get_install_remove_lists func

parent d0cb7e45
......@@ -52,7 +52,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_title("EPM PLAY")
self.checkboxes = None
self.rows = None
self.reset_button.connect("clicked", lambda _: self.update_ui())
......@@ -101,7 +101,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.installed_apps = installed_apps
self.clear_choice_listbox()
self.checkboxes = {}
self.rows = {}
for app in self.applications:
self.add_application_row(app)
......@@ -119,7 +119,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
on_toggle=self.on_checkbox_toggled
)
self.choice_listbox.append(row)
self.checkboxes[app['name']] = row
self.rows[app['name']] = row
def on_checkbox_toggled(self, app_name, active):
print(f"{app_name} {'установлен' if active else 'снят'}")
......@@ -196,12 +196,20 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
), on_done=self.update_ui)
def get_install_remove_lists(self):
if self.installed_apps and self.checkboxes:
to_install = [app_name for app_name, row in self.checkboxes.items() if row.checkbox.get_active() and app_name not in self.installed_apps]
to_remove = [app_name for app_name, row in self.checkboxes.items() if not row.checkbox.get_active() and app_name in self.installed_apps]
return to_install, to_remove
else:
return False, False
if not (self.installed_apps and self.rows):
return [], []
to_install = [
app_name for app_name, row in self.rows.items()
if row.checkbox.get_active() and app_name not in self.installed_apps
]
to_remove = [
app_name for app_name, row in self.rows.items()
if not row.checkbox.get_active() and app_name in self.installed_apps
]
return to_install, to_remove
def build_commands(self, to_install, to_remove):
commands = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment