Ran update-copyright.py
[hooke.git] / hooke / plugin / playlist.py
index 43978b5669f7eba4f58fbb43241fa2dbb6090309..ca800ee5a653f892c7b1f5addca51ae4dbc61820 100644 (file)
@@ -1,20 +1,19 @@
-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
 #
 # 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 ``playlist`` module provides :class:`PlaylistPlugin` and
 several associated :class:`hooke.command.Command`\s for handling
@@ -322,7 +321,7 @@ Additional information for the input :class:`hooke.curve.Curve`.
 
     def _run(self, hooke, inqueue, outqueue, params):
         p = self._playlist(hooke, params)
-        for path in sorted(glob.glob(params['input'])):
+        for path in sorted(glob.glob(os.path.expanduser(params['input']))):
             try:
                 p.append_curve_by_path(path, params['info'], hooke=hooke)
             except NotRecognized, e:
@@ -338,15 +337,19 @@ class RemoveCommand (PlaylistCommand):
         super(RemoveCommand, self).__init__(
             name='remove curve from playlist',
             arguments=[
-                Argument(name='index', type='int', optional=False, help="""
+                Argument(name='index', type='int', optional=True, help="""
 Index of target curve.
 """.strip()),
                 ],
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
-        self._playlist(hooke, params).pop(params['index'])
-        self._playlist(hooke, params).jump(params.index())
+        playlist = self._playlist(hooke, params)
+        if params['index'] is None:
+            params['index'] = playlist.index()
+        curve = playlist.pop(params['index'])
+        playlist.jump(playlist.index())
+        outqueue.put(curve)
 
 
 class ApplyCommand (PlaylistCommand):
@@ -372,7 +375,7 @@ Evaluate the applied command stack immediately.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
-        params = self.__setup_params(hooke=hooke, params=params)
+        params = self._setup_params(hooke=hooke, params=params)
         p = self._playlist(hooke, params)
         if params['evaluate'] == True:
             exec_cmd = hooke.command_by_name['execute command stack']
@@ -387,7 +390,7 @@ Evaluate the applied command stack immediately.
                 curve.set_hooke(hooke)
                 p.unload(curve)
 
-    def __setup_params(self, hooke, params):
+    def _setup_params(self, hooke, params):
         if params['commands'] == None:
             cstack_plugin = [p for p in hooke.plugins
                              if p.name == 'command_stack'][0]