replace generator function with factory function

This commit is contained in:
onyx-and-iris 2023-08-05 14:06:39 +01:00
parent 4af7c0f694
commit 55211b9b19

View File

@ -172,32 +172,24 @@ class VbanMidiOutstream(VbanOutstream):
def _make_stream_pair(remote, kind): def _make_stream_pair(remote, kind):
num_instream, num_outstream, num_midi, num_text = kind.vban num_instream, num_outstream, num_midi, num_text = kind.vban
def _generate_streams(i, dir): def _make_cls(i, dir):
"""generator function for creating instream/outstream tuples""" match dir:
if dir == "in": case "in":
if i < num_instream: if i < num_instream:
yield VbanAudioInstream return VbanAudioInstream(remote, i)
elif i < num_instream + num_midi: elif i < num_instream + num_midi:
yield VbanMidiInstream return VbanMidiInstream(remote, i)
else: else:
yield VbanTextInstream return VbanTextInstream(remote, i)
else: case "out":
if i < num_outstream: if i < num_outstream:
yield VbanAudioOutstream return VbanAudioOutstream(remote, i)
else: else:
yield VbanMidiOutstream return VbanMidiOutstream(remote, i)
return ( return (
tuple( tuple(_make_cls(i, "in") for i in range(num_instream + num_midi + num_text)),
cls(remote, i) tuple(_make_cls(i, "out") for i in range(num_outstream + num_midi)),
for i in range(num_instream + num_midi + num_text)
for cls in _generate_streams(i, "in")
),
tuple(
cls(remote, i)
for i in range(num_outstream + num_midi)
for cls in _generate_streams(i, "out")
),
) )