From e41eadad954dfd4d9a2901f5089cad9de4373cc3 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sun, 5 Nov 2023 19:40:17 -0800 Subject: [PATCH] Fixing some warnings --- wavinfo/riff_parser.py | 19 ++++++------------- wavinfo/wave_reader.py | 5 +++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/wavinfo/riff_parser.py b/wavinfo/riff_parser.py index 47ead92..58db6cc 100644 --- a/wavinfo/riff_parser.py +++ b/wavinfo/riff_parser.py @@ -12,17 +12,6 @@ class WavInfoEOFError(EOFError): class ListChunkDescriptor(namedtuple('ListChunkDescriptor', 'signature children')): pass - # def find(self, chunk_path): - # if len(chunk_path) > 1: - # for chunk in self.children: - # if type(chunk) is ListChunkDescriptor and \ - # chunk.signature is chunk_path[0]: - # return chunk.find(chunk_path[1:]) - # else: - # for chunk in self.children: - # if type(chunk) is ChunkDescriptor and \ - # chunk.ident is chunk_path[0]: - # return chunk class ChunkDescriptor(namedtuple('ChunkDescriptor', 'ident start length rf64_context')): @@ -59,6 +48,7 @@ def parse_chunk(stream, rf64_context=None): if rf64_context is None and ident in {b'RF64', b'BW64'}: rf64_context = parse_rf64(stream=stream, signature=ident) + assert rf64_context is not None data_size = rf64_context.bigchunk_table[ident] displacement = data_size @@ -66,8 +56,11 @@ def parse_chunk(stream, rf64_context=None): displacement += 1 if ident in {b'RIFF', b'LIST', b'RF64', b'BW64'}: - return parse_list_chunk(stream=stream, length=data_size, rf64_context=rf64_context) + return parse_list_chunk(stream=stream, length=data_size, + rf64_context=rf64_context) + else: data_start = stream.tell() stream.seek(displacement, 1) - return ChunkDescriptor(ident=ident, start=data_start, length=data_size, rf64_context=rf64_context) + return ChunkDescriptor(ident=ident, start=data_start, length=data_size, + rf64_context=rf64_context) diff --git a/wavinfo/wave_reader.py b/wavinfo/wave_reader.py index cfce9bb..afb97ff 100644 --- a/wavinfo/wave_reader.py +++ b/wavinfo/wave_reader.py @@ -19,7 +19,8 @@ WavDataDescriptor = namedtuple('WavDataDescriptor', 'byte_count frame_count') #: The format of the audio samples. WavAudioFormat = namedtuple('WavAudioFormat', - 'audio_format channel_count sample_rate byte_rate block_align bits_per_sample') + ['audio_format', 'channel_count', 'sample_rate', + 'byte_rate', 'block_align', 'bits_per_sample']) class WavInfoReader: @@ -80,7 +81,7 @@ class WavInfoReader: absolute_path = os.path.abspath(path) #: `file://` url for the file. - self.url: pathlib.Path = pathlib.Path(absolute_path).as_uri() + self.url: str = pathlib.Path(absolute_path).as_uri() self.path = absolute_path