Cleanups to playlist name handling in 'load playlist'.
authorW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 11:52:01 +0000 (07:52 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 11:52:01 +0000 (07:52 -0400)
Also:
* push new curves to outqueue during 'glob curves to playlist'.
* 'new playlist' transitioned to a subclass of PlaylistAddingCommand.

hooke/plugin/playlist.py
hooke/plugin/playlists.py

index 69cc56227ba106a9736bf1ffc34a3bea1a64c093..912d21c3aad05fc566dc8ddfc99f7df2fadbbedf 100644 (file)
@@ -248,8 +248,8 @@ Drivers for loading curves.
         p = FilePlaylist(drivers=params['drivers'], path=params['input'])
         p.load(hooke=hooke)
         playlist_names = [playlist.name for playlist in hooke.playlists]
-        if p.name not in playlist_names:
-            params['output playlist'] = p.name  # HACK: override input name.  How to tell if it is callback-generated?
+        if p.name in playlist_names:
+            p.name = params['output playlist']  # HACK: override input name.  How to tell if it is callback-generated?
         self._set_playlist(hooke, params, p)
        outqueue.put(p)
 
@@ -300,10 +300,10 @@ Additional information for the input :class:`hooke.curve.Curve`.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
+        p = self._playlist(hooke, params)
         for path in sorted(glob.glob(params['input'])):
-            self._playlist(hooke, params).append_curve_by_path(
-                path, params['info'], hooke=hooke)
-
+            p.append_curve_by_path(path, params['info'], hooke=hooke)
+            outqueue.put(p[-1])
 
 class RemoveCommand (PlaylistCommand):
     """Remove a curve from a playlist.
index c04f0ba1baa13d86f886b5df9a3029c6a9205d59..2194b0409a67e1247a279660375edaa61672bb14 100644 (file)
@@ -24,7 +24,7 @@ lists of :class:`hooke.playlist.Playlist` classes.
 from ..command import Command, Argument, Failure
 from ..playlist import FilePlaylist
 from . import Builtin
-from .playlist import PlaylistNameArgument
+from .playlist import PlaylistNameArgument, PlaylistAddingCommand
 
 
 class PlaylistsPlugin (Builtin):
@@ -100,14 +100,13 @@ class PlaylistListCommand (Command):
        outqueue.put(list(hooke.playlists))
 
 
-class NewCommand (Command):
+class NewCommand (PlaylistAddingCommand):
     """Create a new playlist.
     """
     def __init__(self, plugin):
         super(NewCommand, self).__init__(
             name='new playlist',
             arguments=[
-                PlaylistNameArgument,
                 Argument(name='file', type='file', optional=True,
                          help="""
 Default filename for future saves.
@@ -116,10 +115,11 @@ Default filename for future saves.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
-        print 'PP', params['name']
-        hooke.playlists.append(
-            FilePlaylist(
-                drivers=hooke.drivers,
-                name=params['name'],
-                path=params['file'],
-                ))
+        p = FilePlaylist(
+            drivers=hooke.drivers,
+            path=params['file'],
+            )
+        playlist_names = [playlist.name for playlist in hooke.playlists]
+        if p.name in playlist_names:
+            p.name = params['output playlist']  # HACK: override input name.  How to tell if it is callback-generated?
+        hooke.playlists.append(p)