mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
Fixing walk
And adding to_dict method to ADM
This commit is contained in:
24
tests/test_adm.py
Normal file
24
tests/test_adm.py
Normal 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()
|
||||||
|
|
||||||
@@ -89,3 +89,13 @@ class WavIXMLFormat:
|
|||||||
The name of this file's file family.
|
The name of this file's file family.
|
||||||
"""
|
"""
|
||||||
return self._get_text_value("FILE_SET/FAMILY_NAME")
|
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
|
||||||
|
)
|
||||||
|
|||||||
@@ -151,22 +151,29 @@ class WavInfoReader:
|
|||||||
metadata field, and the value.
|
metadata field, and the value.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
scopes = ('fmt', 'data') # 'bext', 'ixml', 'info')
|
scopes = ('fmt', 'data', 'ixml', 'bext', 'info')
|
||||||
|
|
||||||
for scope in scopes:
|
for scope in scopes:
|
||||||
attr = self.__getattribute__(scope)
|
if scope in ['fmt', 'data']:
|
||||||
for field in attr._fields:
|
attr = self.__getattribute__(scope)
|
||||||
yield scope, field, attr.__getattribute__(field)
|
for field in attr._fields:
|
||||||
|
yield scope, field, attr.__getattribute__(field)
|
||||||
|
|
||||||
if self.bext is not None:
|
if scope in ['bext']:
|
||||||
bext_dict = (self.bext or {}).to_dict()
|
bext_dict = self.bext.to_dict() if self.bext else {}
|
||||||
for key in bext_dict.keys():
|
for key in bext_dict.keys():
|
||||||
yield 'bext', key, bext_dict[key]
|
yield 'bext', key, bext_dict[key]
|
||||||
|
|
||||||
if self.info is not None:
|
if scope in ['info']:
|
||||||
info_dict = self.info.to_dict()
|
info_dict = self.info.to_dict() if self.info else {}
|
||||||
for key in info_dict.keys():
|
for key in info_dict.keys():
|
||||||
yield 'info', key, info_dict[key]
|
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):
|
def __repr__(self):
|
||||||
return 'WavInfoReader({}, {}, {})'.format(self.path, self.info_encoding, self.bext_encoding)
|
return 'WavInfoReader({}, {}, {})'.format(self.path, self.info_encoding, self.bext_encoding)
|
||||||
|
|||||||
Reference in New Issue
Block a user