Skip to content

Commit

Permalink
Add ternary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed May 29, 2024
1 parent 573cf26 commit bfdc30b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions napari_plugin_manager/qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,17 +1032,9 @@ def _add_items(self, items=None):
self._add_items_timer.stop()
return

if items is None:
length = 2
else:
length = len(items)

length = 2 if items is None else len(items)
for _ in range(length):
if items is None:
data = self._plugin_data.pop(0)
else:
data = items.pop(0)

data = self._plugin_data.pop(0) if items is None else items.pop(0)
project_info, is_available_in_conda, extra_info = data
if project_info.name in self.already_installed:
self.installed_list.tag_outdated(
Expand Down Expand Up @@ -1082,7 +1074,7 @@ def _handle_yield(self, data: Tuple[npe2.PackageMetadata, bool, Dict]):
for i in self.all_plugin_data
]

def search(self, text):
def _search(self, text):
idxs = []
for idx, item in enumerate(self.filter_texts):
if text.lower() in item and idx not in self._filter_idxs_cache:
Expand All @@ -1102,7 +1094,7 @@ def filter(self, text: Optional[str] = None, skip=False) -> None:

# TODO: This is a workaround for the fact that the available list
if not skip and self.available_list.is_running() and len(text) >= 1:
items = [self.all_plugin_data[idx] for idx in self.search(text)]
items = [self.all_plugin_data[idx] for idx in self._search(text)]
if items:
self._add_items(items)

Expand Down

0 comments on commit bfdc30b

Please sign in to comment.