Run update-copyright.py.
[hooke.git] / hooke / plugin / playlists.py
index 8de9ec1f643323d5fa1fb555f9e1203dcbda2665..a50065c0b7e3f2d3e4143de5a8772578c01a7f5b 100644 (file)
@@ -1,20 +1,19 @@
-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
 #
 # This file is part of Hooke.
 #
-# Hooke is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
 #
-# Hooke is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
-# Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
 #
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke.  If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
 
 """The ``playlists`` module provides :class:`PlaylistsPlugin` and
 several associated :class:`hooke.command.Command`\s for handling
@@ -23,8 +22,8 @@ lists of :class:`hooke.playlist.Playlist` classes.
 
 from ..command import Command, Argument, Failure
 from ..playlist import FilePlaylist
-from ..plugin import Builtin
-from .playlist import PlaylistNameArgument
+from . import Builtin
+from .playlist import PlaylistNameArgument, PlaylistAddingCommand
 
 
 class PlaylistsPlugin (Builtin):
@@ -100,14 +99,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 +114,9 @@ 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'],
+            )
+        self._set_playlist(hooke, params, p)
+        outqueue.put(p)