Restyled by black

This commit is contained in:
Restyled.io
2021-04-09 23:16:18 +00:00
parent 45e69da1a8
commit cc49433aa9
9 changed files with 78 additions and 63 deletions

View File

@@ -18,7 +18,8 @@ class DeviceStateHandler:
_deviceInfo: Connect.DeviceInfo = None
_listeners: list[DeviceStateHandler.Listener] = list()
_putState: Connect.PutStateRequest = None
_putStateWorker: concurrent.futures.ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor(
_putStateWorker: concurrent.futures.ThreadPoolExecutor = (
concurrent.futures.ThreadPoolExecutor()
)
_connectionId: str = None
@@ -30,11 +31,11 @@ class DeviceStateHandler:
def _update_connection_id(self, newer: str) -> None:
newer = urllib.parse.unquote(newer, "UTF-8")
if self._connectionId is None or \
self._connectionId != newer:
if self._connectionId is None or self._connectionId != newer:
self._connectionId = newer
self._LOGGER.debug("Updated Spotify-Connection-Id: {}".format(
self._connectionId))
self._LOGGER.debug(
"Updated Spotify-Connection-Id: {}".format(self._connectionId)
)
self._notify_ready()
def add_listener(self, listener: DeviceStateHandler.Listener):
@@ -44,8 +45,12 @@ class DeviceStateHandler:
for listener in self._listeners:
listener.ready()
def update_state(self, reason: Connect.PutStateReason, player_time: int,
state: Player.PlayerState):
def update_state(
self,
reason: Connect.PutStateReason,
player_time: int,
state: Player.PlayerState,
):
if self._connectionId is None:
raise TypeError()
@@ -63,10 +68,13 @@ class DeviceStateHandler:
def _put_connect_state(self, req: Connect.PutStateRequest):
self._session.api().put_connect_state(self._connectionId, req)
self._LOGGER.info("Put state. ts: {}, connId: {}, reason: {}".format(
req.client_side_timestamp,
Utils.truncate_middle(self._connectionId, 10),
req.put_state_reason))
self._LOGGER.info(
"Put state. ts: {}, connId: {}, reason: {}".format(
req.client_side_timestamp,
Utils.truncate_middle(self._connectionId, 10),
req.put_state_reason,
)
)
class Endpoint(enum.Enum):
Play: str = "play"
@@ -80,8 +88,11 @@ class DeviceStateHandler:
def ready(self) -> None:
pass
def command(self, endpoint: DeviceStateHandler.Endpoint,
data: DeviceStateHandler.CommandBody) -> None:
def command(
self,
endpoint: DeviceStateHandler.Endpoint,
data: DeviceStateHandler.CommandBody,
) -> None:
pass
def volume_changed(self) -> None: