Fixing walk

And adding to_dict method to
ADM
This commit is contained in:
Jamie Hardt
2022-11-23 11:43:47 -08:00
parent 5b9d326e94
commit a063fffb41
3 changed files with 49 additions and 8 deletions

24
tests/test_adm.py Normal file
View File

@@ -0,0 +1,24 @@
from unittest import TestCase
import wavinfo
class TestADMWave(TestCase):
def setUp(self) -> None:
self.protools_adm_wav = "tests/test_files/protools/Test_ADM_ProTools.wav"
return super().setUp()
def test_chna(self):
info = wavinfo.WavInfoReader(self.protools_adm_wav)
self.assertIsNotNone(info)
adm = info.adm
self.assertIsNotNone(adm)
self.assertEqual(len(adm.channel_uids), 14)
# def test_to_dict(self):
# info = wavinfo.WavInfoReader(self.protools_adm_wav)
# adm = info.adm
# dict = adm.to_dict()

View File

@@ -89,3 +89,13 @@ class WavIXMLFormat:
The name of this file's file family.
"""
return self._get_text_value("FILE_SET/FAMILY_NAME")
def to_dict(self):
return dict(track_list=list(map(lambda x: x._asdict(), self.track_list)),
project=self.project,
scene=self.scene,
take=self.take,
tape=self.tape,
family_uid=self.family_uid,
family_name=self.family_name
)

View File

@@ -151,22 +151,29 @@ class WavInfoReader:
metadata field, and the value.
"""
scopes = ('fmt', 'data') # 'bext', 'ixml', 'info')
scopes = ('fmt', 'data', 'ixml', 'bext', 'info')
for scope in scopes:
attr = self.__getattribute__(scope)
for field in attr._fields:
yield scope, field, attr.__getattribute__(field)
if scope in ['fmt', 'data']:
attr = self.__getattribute__(scope)
for field in attr._fields:
yield scope, field, attr.__getattribute__(field)
if self.bext is not None:
bext_dict = (self.bext or {}).to_dict()
if scope in ['bext']:
bext_dict = self.bext.to_dict() if self.bext else {}
for key in bext_dict.keys():
yield 'bext', key, bext_dict[key]
if self.info is not None:
info_dict = self.info.to_dict()
if scope in ['info']:
info_dict = self.info.to_dict() if self.info else {}
for key in info_dict.keys():
yield 'info', key, info_dict[key]
if scope in ['ixml']:
ixml_dict = self.ixml.to_dict() if self.ixml else {}
for key in ixml_dict.keys():
yield 'ixml', key, ixml_dict[key]
def __repr__(self):
return 'WavInfoReader({}, {}, {})'.format(self.path, self.info_encoding, self.bext_encoding)