Remove unused Config.wav_prefix and update tests

It was intended that Channel.wav_path was stored and loaded relative to
Config.wav_prefix, but this was never implemented (neither saving nor
loading.)

This change simplifies code, and eliminates some inconsistency (Config.
master_audio was never planned to be relative to Config.wav_prefix).
pull/357/head preview-time-trax
nyanpasu64 2018-08-20 01:13:47 -07:00
rodzic 245704256a
commit e9c0a21469
4 zmienionych plików z 7 dodań i 32 usunięć

Wyświetl plik

@ -87,16 +87,15 @@ def main(
# Create cfg: Config object.
cfg: Config = None
wav_prefix = Path()
wav_list: List[Path] = []
for name in files:
path = Path(name)
if path.is_dir():
# Add a directory.
if len(files) > 1:
# Warning is technically optional, since wav_prefix has been removed.
raise click.ClickException(
f'When supplying folder {path}, you cannot supply other files/folders')
wav_prefix = path
matches = sorted(path.glob('*.wav'))
wav_list += matches
break
@ -120,7 +119,6 @@ def main(
wav_list += matches
if not cfg:
wav_prefix = str(wav_prefix)
wav_list = [str(wav_path) for wav_path in wav_list]
channels = [ChannelConfig(wav_path) for wav_path in wav_list]
@ -130,13 +128,9 @@ def main(
else:
outputs = [FFplayOutputConfig()]
# TODO test cfg, ensure wav_prefix and wav_list are correct
# maybe I should use a list comprehension to parse cfg.channels to List[str].
cfg = default_config(
master_audio=audio,
# fps=default,
wav_prefix=wav_prefix,
channels=channels,
# width_ms...trigger=default,
# amplification...render=default,

Wyświetl plik

@ -26,13 +26,12 @@ class BenchmarkMode(IntEnum):
OUTPUT = 3
@register_config(always_dump='begin_time wave_prefix')
@register_config(always_dump='begin_time')
class Config:
master_audio: Optional[str]
fps: int
begin_time: float = 0
wav_prefix: str = '' # if wave/glob..., pwd. if folder, folder.
channels: List[ChannelConfig] = field(default_factory=list)
width_ms: int
@ -69,7 +68,6 @@ def default_config(**kwargs):
fps=_FPS,
# begin_time=0,
# wav_prefix='',
channels=[],
width_ms=25,

Wyświetl plik

@ -1,15 +0,0 @@
# import pytest
#
# from ovgenpy import channel
# from ovgenpy.ovgenpy import default_config
# from ovgenpy.triggers import NullTriggerConfig
#
#
# @pytest.mark.parametrize('wav_prefix', '. nonexistent'.split())
# def test_channel_prefix(wav_prefix, mocker):
# """ Test that channels are created with the correct wav_prefix. """
#
# # Create channels, but stub out wave files.
# mocker.patch.object(channel, 'Wave')
#
# cfg = default_config(trigger=NullTriggerConfig())

Wyświetl plik

@ -66,14 +66,12 @@ def test_no_files(any_sink):
any_sink('')
@pytest.mark.parametrize('folder', '. wav-formats'.split())
def test_cwd(any_sink, folder, mocker):
""" wav_prefix"""
wavs = Path(folder).glob('*.wav')
wavs = sorted(x.name for x in wavs)
@pytest.mark.parametrize('wav_dir', '. tests'.split())
def test_cwd(any_sink, wav_dir):
wavs = Path(wav_dir).glob('*.wav')
wavs = sorted(str(x) for x in wavs)
cfg = any_sink(folder)
cfg = any_sink(wav_dir)
assert isinstance(cfg, Config)
assert cfg.wav_prefix == folder
assert [chan.wav_path for chan in cfg.channels] == wavs