black -t py34

This commit is contained in:
LtPeriwinkle 2020-06-24 12:22:03 -07:00
parent e1a9782458
commit 7215a11ffe

View file

@ -5,6 +5,7 @@ import core.module
import core.widget import core.widget
import core.input import core.input
import core.decorators import core.decorators
"""Displays the current song being played and allows pausing, skipping ahead, and skipping back. """Displays the current song being played and allows pausing, skipping ahead, and skipping back.
Requires the following library: Requires the following library:
@ -17,11 +18,15 @@ Parameters:
Widget names are: spotify-buttons.song, spotify-buttons.prev, spotify-buttons.pause, spotify-buttons.next Widget names are: spotify-buttons.song, spotify-buttons.prev, spotify-buttons.pause, spotify-buttons.next
""" """
class Module(core.module.Module): class Module(core.module.Module):
def __init__(self, config, theme): def __init__(self, config, theme):
super().__init__(config, theme, []) super().__init__(config, theme, [])
self.__layout = self.parameter("layout", "spotify-buttons.song spotify-buttons.prev spotify-buttons.pause spotify-buttons.next") self.__layout = self.parameter(
"layout",
"spotify-buttons.song spotify-buttons.prev spotify-buttons.pause spotify-buttons.next",
)
self.__song = "" self.__song = ""
self.__pause = "" self.__pause = ""
@ -55,34 +60,36 @@ class Module(core.module.Module):
artist=",".join(props.get("xesam:artist")), artist=",".join(props.get("xesam:artist")),
trackNumber=str(props.get("xesam:trackNumber")), trackNumber=str(props.get("xesam:trackNumber")),
) )
#this feels like a stupid way to do this but its all i can think of # this feels like a stupid way to do this but its all i can think of
widget_map = {} widget_map = {}
for widget_name in self.__layout.split(): for widget_name in self.__layout.split():
widget = self.add_widget(name = widget_name) widget = self.add_widget(name=widget_name)
if widget_name == "spotify-buttons.prev": if widget_name == "spotify-buttons.prev":
widget_map[widget] = { widget_map[widget] = {
"button": core.input.LEFT_MOUSE, "button": core.input.LEFT_MOUSE,
"cmd": self.__cmd + "Previous", "cmd": self.__cmd + "Previous",
} }
widget.full_text("\u258F\u25C0") widget.full_text("\u258F\u25C0")
elif widget_name == "spotify-buttons.pause": elif widget_name == "spotify-buttons.pause":
widget_map[widget] = { widget_map[widget] = {
"button": core.input.LEFT_MOUSE, "button": core.input.LEFT_MOUSE,
"cmd": self.__cmd + "PlayPause", "cmd": self.__cmd + "PlayPause",
} }
widget.full_text(self.__pause) widget.full_text(self.__pause)
elif widget_name == "spotify-buttons.next": elif widget_name == "spotify-buttons.next":
widget_map[widget] = { widget_map[widget] = {
"button": core.input.LEFT_MOUSE, "button": core.input.LEFT_MOUSE,
"cmd": self.__cmd + "Next", "cmd": self.__cmd + "Next",
} }
widget.full_text("\u25B6\u2595") widget.full_text("\u25B6\u2595")
elif widget_name == "spotify-buttons.song": elif widget_name == "spotify-buttons.song":
widget.full_text(self.__song) widget.full_text(self.__song)
else: else:
raise KeyError( raise KeyError(
"The spotify-buttons module does not have a {widget_name!r} widget".format(widget_name=widget_name) "The spotify-buttons module does not have a {widget_name!r} widget".format(
widget_name=widget_name
) )
)
for widget, callback_options in widget_map.items(): for widget, callback_options in widget_map.items():
core.input.register(widget, **callback_options) core.input.register(widget, **callback_options)