Skip to content

Commit

Permalink
Use operator convenience functions
Browse files Browse the repository at this point in the history
  • Loading branch information
infirit committed Sep 19, 2023
1 parent f7eb687 commit 513536d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions blueman/gui/manager/ManagerDeviceMenu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from enum import Enum, auto
from gettext import gettext as _
from operator import attrgetter
from typing import Dict, List, Tuple, Optional, TYPE_CHECKING, Union, Iterable

from blueman.Functions import create_menuitem, e_
Expand Down Expand Up @@ -306,12 +307,12 @@ def generate(self) -> None:

if connect_items:
self.append(self._create_header(_("<b>Connect To:</b>")))
for it in sorted(connect_items, key=lambda i: i.position):
for it in sorted(connect_items, key=attrgetter("position")):
self.append(it.item)

if disconnect_items:
self.append(self._create_header(_("<b>Disconnect:</b>")))
for it in sorted(disconnect_items, key=lambda i: i.position):
for it in sorted(disconnect_items, key=attrgetter("position")):
self.append(it.item)

config = AutoConnectConfig()
Expand All @@ -328,15 +329,15 @@ def generate(self) -> None:
item.show()
self.append(item)

for it in sorted(autoconnect_items, key=lambda i: i.position):
for it in sorted(autoconnect_items, key=attrgetter("position")):
self.append(it.item)

if show_generic_connect or connect_items or disconnect_items or autoconnect_items:
item = Gtk.SeparatorMenuItem()
item.show()
self.append(item)

for it in sorted(action_items, key=lambda i: i.position):
for it in sorted(action_items, key=attrgetter("position")):
self.append(it.item)

send_item = create_menuitem(_("Send a _File…"), "blueman-send-symbolic")
Expand Down
3 changes: 2 additions & 1 deletion blueman/plugins/applet/StatusIcon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from gettext import gettext as _
from operator import itemgetter
from typing import Optional, Tuple, List

from gi.repository import GObject, GLib, Gio
Expand Down Expand Up @@ -117,7 +118,7 @@ def _get_status_icon_implementations(self) -> List[str]:
return [implementation for implementation, _ in sorted(
(plugin.on_query_status_icon_implementation()
for plugin in self.parent.Plugins.get_loaded_plugins(StatusIconImplementationProvider)),
key=lambda implementation_priority: implementation_priority[1],
key=itemgetter(1),
reverse=True
)] + ["GtkStatusIcon"]

Expand Down

0 comments on commit 513536d

Please sign in to comment.