Skip to content

Commit bfe1a0c

Browse files
committed
_selected_tags(): make it a generator
1 parent 94c5eda commit bfe1a0c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

picard/ui/metadatabox.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def _get_editor_value(editor):
361361
def contextMenuEvent(self, event):
362362
menu = QtWidgets.QMenu(self)
363363
if self.objects:
364-
tags = self._selected_tags()
364+
tags = list(self._selected_tags())
365365
single_tag = len(tags) == 1
366366
if single_tag:
367367
selected_tag = tags[0]
@@ -459,7 +459,7 @@ def _edit_tag(self, tag):
459459
EditTagDialog(self.parent, tag).exec()
460460

461461
def _edit_selected_tag(self):
462-
tags = self._selected_tags(filter_func=self._tag_is_editable)
462+
tags = list(self._selected_tags(filter_func=self._tag_is_editable))
463463
if len(tags) == 1:
464464
self._edit_tag(tags[0])
465465

@@ -498,11 +498,10 @@ def _tag_is_editable(self, tag):
498498
return self.tag_diff.status[tag] & TagStatus.READONLY == 0
499499

500500
def _selected_tags(self, filter_func=None):
501-
tags = set(self.tag_diff.tag_names[item.row()]
502-
for item in self.selectedItems())
503-
if filter_func:
504-
tags = filter(filter_func, tags)
505-
return list(tags)
501+
for tag in set(self.tag_diff.tag_names[item.row()]
502+
for item in self.selectedItems()):
503+
if filter_func is None or filter_func(tag):
504+
yield tag
506505

507506
def _update_selection(self):
508507
files = set()

0 commit comments

Comments
 (0)