Format code with yapf

This commit fixes the style issues introduced in 2790f48 according to the output
from yapf.

Details: https://deepsource.io/gh/kokarare1212/librespot-python/transform/04a80a03-ea85-44b3-9159-2580bda68c1c/
This commit is contained in:
deepsource-autofix[bot]
2021-09-12 04:58:42 +00:00
committed by GitHub
parent 2790f484c8
commit 0741dbdd43
15 changed files with 396 additions and 237 deletions

View File

@@ -50,21 +50,25 @@ class ChannelManager(Closeable, PacketsReceiver):
chunk_id = struct.unpack(">H", payload.read(2))[0]
channel = self.channels.get(chunk_id)
if channel is None:
self.logger.warning("Couldn't find channel, id: {}, received: {}"
.format(chunk_id, len(packet.payload)))
self.logger.warning(
"Couldn't find channel, id: {}, received: {}".format(
chunk_id, len(packet.payload)))
return
channel.add_to_queue(payload)
elif packet.is_cmd(Packet.Type.channel_error):
chunk_id = struct.unpack(">H", payload.read(2))[0]
channel = self.channels.get(chunk_id)
if channel is None:
self.logger.warning("Dropping channel error, id: {}, code: {}"
.format(chunk_id, struct.unpack(">H", payload.read(2))[0]))
self.logger.warning(
"Dropping channel error, id: {}, code: {}".format(
chunk_id,
struct.unpack(">H", payload.read(2))[0]))
return
channel.stream_error(struct.unpack(">H", payload.read(2))[0])
else:
self.logger.warning("Couldn't handle packet, cmd: {}, payload: {}"
.format(packet.cmd, util.bytes_to_hex(packet.payload)))
self.logger.warning(
"Couldn't handle packet, cmd: {}, payload: {}".format(
packet.cmd, util.bytes_to_hex(packet.payload)))
def close(self) -> None:
self.executor_service.shutdown()
@@ -86,14 +90,16 @@ class ChannelManager(Closeable, PacketsReceiver):
with self.channel_manager.seq_holder_lock:
self.chunk_id = self.channel_manager.seq_holder
self.channel_manager.seq_holder += 1
self.channel_manager.executor_service.submit(lambda: ChannelManager.Channel.Handler(self))
self.channel_manager.executor_service.submit(
lambda: ChannelManager.Channel.Handler(self))
def _handle(self, payload: bytes) -> bool:
if len(payload) == 0:
if not self.__header:
self.__file.write_chunk(payload, self.__chunk_index, False)
return True
self.channel_manager.logger.debug("Received empty chunk, skipping.")
self.channel_manager.logger.debug(
"Received empty chunk, skipping.")
return False
if self.__header:
length: int
@@ -123,7 +129,10 @@ class ChannelManager(Closeable, PacketsReceiver):
self.__channel = channel
def run(self) -> None:
self.__channel.channel_manager.logger.debug("ChannelManager.Handler is starting")
self.__channel.channel_manager.logger.debug(
"ChannelManager.Handler is starting")
with self.__channel.q.all_tasks_done:
self.__channel.channel_manager.channels.pop(self.__channel.chunk_id)
self.__channel.channel_manager.logger.debug("ChannelManager.Handler is shutting down")
self.__channel.channel_manager.channels.pop(
self.__channel.chunk_id)
self.__channel.channel_manager.logger.debug(
"ChannelManager.Handler is shutting down")