X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Faction.py;h=1a2abe203567a496802824c68c1ae3113b57eb47;hb=a24c34bc1458c4b0962773d804fac4d325632ee8;hp=792b123cd2676c37bca6c72f2c7905aaf06b6578;hpb=6f4944c18398a7482297bd1d80fcd4ee926270ae;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/action.py b/helpers/action.py index 792b123..1a2abe2 100644 --- a/helpers/action.py +++ b/helpers/action.py @@ -1,6 +1,8 @@ import threading import time +from . import debug_print + class Action: action_types = [ 'command', @@ -32,7 +34,7 @@ class Action: return True def run(self): - print(self.description()) + debug_print(self.description()) getattr(self, self.action)(**self.arguments) def description(self): @@ -42,17 +44,17 @@ class Action: if getattr(self, self.action + "_interrupt", None): return getattr(self, self.action + "_interrupt")(**self.arguments) - # Actions - def command(self, command = "", **kwargs): - # FIXME: todo - pass - def music_list(self, music): if music is not None: return [music] else: return self.mapping.open_files.values() + # Actions + def command(self, command = "", **kwargs): + # FIXME: todo + pass + def pause(self, music = None, **kwargs): for music in self.music_list(music): if music.is_loaded_playing(): @@ -67,7 +69,7 @@ class Action: restart_if_running = False, volume = 100, loop = 0, **kwargs): - if music is not None: + for music in self.music_list(music): if restart_if_running: if music.is_not_stopped(): music.stop() @@ -131,7 +133,7 @@ class Action: if music is not None: message += "« {} »".format(music.name) else: - message += "music" + message += "all musics" if start_at != 0: message += " at {}s".format(start_at)