mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 08:56:19 +00:00
Reformat code using black
Segments where readability was hampered were fixed by appropriate format skipping directives. New code should hopefully be black compatible. The moment they remove the -S option is probably the moment I stop using black though.
This commit is contained in:
@ -36,13 +36,17 @@ __all__ = (
|
||||
'OggStream',
|
||||
)
|
||||
|
||||
|
||||
class OggError(DiscordException):
|
||||
"""An exception that is thrown for Ogg stream parsing errors."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# https://tools.ietf.org/html/rfc3533
|
||||
# https://tools.ietf.org/html/rfc7845
|
||||
|
||||
|
||||
class OggPage:
|
||||
_header: ClassVar[struct.Struct] = struct.Struct('<xBQIIIB')
|
||||
if TYPE_CHECKING:
|
||||
@ -57,11 +61,10 @@ class OggPage:
|
||||
try:
|
||||
header = stream.read(struct.calcsize(self._header.format))
|
||||
|
||||
self.flag, self.gran_pos, self.serial, \
|
||||
self.pagenum, self.crc, self.segnum = self._header.unpack(header)
|
||||
self.flag, self.gran_pos, self.serial, self.pagenum, self.crc, self.segnum = self._header.unpack(header)
|
||||
|
||||
self.segtable: bytes = stream.read(self.segnum)
|
||||
bodylen = sum(struct.unpack('B'*self.segnum, self.segtable))
|
||||
bodylen = sum(struct.unpack('B' * self.segnum, self.segtable))
|
||||
self.data: bytes = stream.read(bodylen)
|
||||
except Exception:
|
||||
raise OggError('bad data stream') from None
|
||||
@ -76,7 +79,7 @@ class OggPage:
|
||||
partial = True
|
||||
else:
|
||||
packetlen += seg
|
||||
yield self.data[offset:offset+packetlen], True
|
||||
yield self.data[offset : offset + packetlen], True
|
||||
offset += packetlen
|
||||
packetlen = 0
|
||||
partial = False
|
||||
@ -84,6 +87,7 @@ class OggPage:
|
||||
if partial:
|
||||
yield self.data[offset:], False
|
||||
|
||||
|
||||
class OggStream:
|
||||
def __init__(self, stream: IO[bytes]) -> None:
|
||||
self.stream: IO[bytes] = stream
|
||||
|
Reference in New Issue
Block a user