From f760ade28f417e1b83a057ace84edbdcda2939f8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 22 Aug 2010 01:49:02 -0400 Subject: [PATCH] Add `name playlist' command. To avoid collisions if you load the same playlist twice, etc. --- doc/tutorial.txt | 6 ++++++ hooke/plugin/playlist.py | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/tutorial.txt b/doc/tutorial.txt index be41a0d..65d288e 100644 --- a/doc/tutorial.txt +++ b/doc/tutorial.txt @@ -200,6 +200,12 @@ will jump to the 14th curve in the zero-indexed playlist. Replace ``curve`` with ``playlist`` in the above commands to navigate around through the list of loaded playlists. +Because the playlist name is usually saved in the playlist file +itself, there is a ``name_playlist`` command that allows you to rename +playlists on the fly. + + hooke> name_playlist 'my old playlist' + Taking notes ------------ diff --git a/hooke/plugin/playlist.py b/hooke/plugin/playlist.py index 086fa97..ed904c6 100644 --- a/hooke/plugin/playlist.py +++ b/hooke/plugin/playlist.py @@ -38,7 +38,7 @@ class PlaylistPlugin (Builtin): self._commands = [ NextCommand(self), PreviousCommand(self), JumpCommand(self), GetCommand(self), IndexCommand(self), CurveListCommand(self), - SaveCommand(self), LoadCommand(self), + NameCommand(self), SaveCommand(self), LoadCommand(self), AddCommand(self), AddGlobCommand(self), RemoveCommand(self), ApplyCommand(self), FilterCommand(self), @@ -210,6 +210,26 @@ class CurveListCommand (PlaylistCommand): outqueue.put(list(self._playlist(hooke, params))) +class NameCommand (PlaylistCommand): + """(Re)name a playlist. + """ + def __init__(self, plugin): + super(NameCommand, self).__init__( + name='name playlist', + arguments=[ + Argument(name='name', type='string', optional=False, + help=""" +Name for the playlist. +""".strip()), + ], + help=self.__doc__, plugin=plugin) + + def _run(self, hooke, inqueue, outqueue, params): + p = self._playlist(hooke, params) + p.name = params['name'] + outqueue.put(p) + + class SaveCommand (PlaylistCommand): """Save a playlist. """ -- 2.26.2