From be2bcef6fafa0c21e530be253e882136a342feac Mon Sep 17 00:00:00 2001 From: Lars Vierbergen Date: Fri, 17 Mar 2017 19:19:01 +0100 Subject: [PATCH] Format code --- modules/toggle.py | 1 + modules/volume.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/toggle.py b/modules/toggle.py index 7b558c9..10978b6 100644 --- a/modules/toggle.py +++ b/modules/toggle.py @@ -15,6 +15,7 @@ class ToggleControl(AbstractControl, metaclass=abc.ABCMeta): The toggle button will show a text in upper or lower case, depending on the activation state of the button. A click on the button toggles the button by calling toggle() """ + def __init__(self, letter: str, initial_state: bool = False): """ :param letter: The text to show on the toggle control. Will be upper- or lowercased when the button is activated or deactivated. diff --git a/modules/volume.py b/modules/volume.py index 4233f56..0f7bcdc 100644 --- a/modules/volume.py +++ b/modules/volume.py @@ -44,10 +44,10 @@ class AbstractVolumeControl(AbstractControl, metaclass=abc.ABCMeta): volume = 1.0 if self.muted: self.muted = False - if int(self._volume) != int(volume*90000): + if int(self._volume) != int(volume * 90000): logger.info("Setting volume to %s", volume) if self._set_volume(volume): - self._volume = int(volume*90000) + self._volume = int(volume * 90000) def __init__(self): super().__init__() @@ -56,7 +56,7 @@ class AbstractVolumeControl(AbstractControl, metaclass=abc.ABCMeta): def respond_to(self, command): if command[0] == '=': - self.volume = int(command[1:])/10.0 + self.volume = int(command[1:]) / 10.0 elif command == 'm1': self.muted = True elif command == 'm0': @@ -64,11 +64,11 @@ class AbstractVolumeControl(AbstractControl, metaclass=abc.ABCMeta): elif command == 'mt': self.muted = not self.muted elif command == '+': - self.volume += 1/30.0 + self.volume += 1 / 30.0 elif command == '-': - self.volume -= 1/30.0 + self.volume -= 1 / 30.0 elif command == 'r': - self.volume = 1/3.0 + self.volume = 1 / 3.0 else: return False return True @@ -117,7 +117,7 @@ def partial_bar(bar_size): class PaCtlVolumeControl(AbstractVolumeControl): def _set_volume(self, volume: float) -> bool: try: - self._pactl('set-sink-volume', str(int(volume*90000))) + self._pactl('set-sink-volume', str(int(volume * 90000))) return True except subprocess.CalledProcessError: logger.exception("Error setting volume") @@ -140,6 +140,7 @@ class PaCtlVolumeControl(AbstractVolumeControl): try: import pulsectl + class PulseCtlVolumeControl(AbstractVolumeControl): def __init__(self): super().__init__() @@ -149,7 +150,8 @@ try: def periodic(self): server_info = self.__pulse.server_info() - self.__default_sink = next(filter(lambda sink: sink.name == server_info.default_sink_name, self.__pulse.sink_list())) + self.__default_sink = next( + filter(lambda sink: sink.name == server_info.default_sink_name, self.__pulse.sink_list())) prev_muted = self.muted self.muted = bool(self.__default_sink.mute) prev_volume = self.volume