Skip to content

Commit

Permalink
Adjusting the hush function to work with documentation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
taconi committed Jan 24, 2025
1 parent bf373c4 commit 7067004
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion sardine_core/sequences/tidal_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,33 @@ def tidal(key, pattern=None, data_only: bool = False):


def hush_factory(env, osc_client, tidal_players):
def hush():
def _hush_all():
for stream in __streams.values():
stream.pattern = silence
tidal_players.remove(stream)
__streams.clear()

def _hush(pat):
streams = (
(n, s) for n, s in __streams.items() if pat in [n, s.name]
)
name, stream = next(streams, (None, None))
if not stream:
raise TypeError(f'Stream "{pat}" not found')

stream.pattern = silence
tidal_players.remove(stream)
__streams.pop(name)

def hush(pat=None):
if pat is None:
return _hush_all()
if isinstance(pat, str):
return _hush(pat)
if not hasattr(pat, 'name') or not isinstance(pat.name, str):
raise TypeError(f'Object of type {type(pat)} is not recognized')
_hush(pat.name)

return hush


Expand Down

0 comments on commit 7067004

Please sign in to comment.