diff --git a/tests/test_adm.py b/tests/test_adm.py new file mode 100644 index 0000000..c6d475d --- /dev/null +++ b/tests/test_adm.py @@ -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() + diff --git a/wavinfo/wave_ixml_reader.py b/wavinfo/wave_ixml_reader.py index 3dd82cd..7f290a5 100644 --- a/wavinfo/wave_ixml_reader.py +++ b/wavinfo/wave_ixml_reader.py @@ -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 + ) diff --git a/wavinfo/wave_reader.py b/wavinfo/wave_reader.py index 228d843..2099a7a 100644 --- a/wavinfo/wave_reader.py +++ b/wavinfo/wave_reader.py @@ -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)