As Hooke launches, you should see something like the following in your
terminal::
- Hooke version 0.8.0 Seinei
+ Hooke version 0.9.0.devel (Kenzo)
- COPYRIGHT
+ Copyright (C) 2006-2010 A. Seeholzer, Alberto Gomez-Casado, Allen
+ Chen, Fabrizio Benedetti, Francesco Musiani, Marco Brucale, Massimo
+ Sandal, Pancaldi Paolo, Richard Naud, Rolf Schmidt, W. Trevor King
+
+ Hooke comes with ABSOLUTELY NO WARRANTY and is licensed under the GNU
+ Lesser General Public License. For details, run `license`.
----
hooke>
mycurve.001
...
-Now you are ready to generate the playlist. The command to use is
-``glob_curves_to_playlist``.::
+Now you are ready to generate the playlist. First, create a blank playlist:
+
+ hooke> new_playlist --name mylist
+
+Ensure that the new playlist is active:
+
+ hooke> jump_to_playlist -- -1
+ hooke> get_playlist
+ <FilePlaylist mylist>
+
+The ``--`` in the ``jump_to_playlist`` command lets
+``jump_to_playlist`` know that ``-1`` is an argument and not an
+option. Using the bare ``--`` is a POSIX specification [#]_ supported
+by the `optparse module`_.
+
+.. _optparse module:
+ http://docs.python.org/library/optparse.html#callback-example-6-variable-arguments
+
+.. [#]: `Guideline 10 of POSIX:2008's section 12.2 <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02>` states:
+
+ "The first -- argument that is not an option-argument should be
+ accepted as a delimiter indicating the end of options. Any
+ following arguments should be treated as operands, even if they
+ begin with the '-' character."
+
+Then glob your curves onto the new list
hooke> glob_curves_to_playlist mycurve.*
will take only curves from :file:`mycurve.050` to :file:`mycurve.059`.
-Note that by using ``glob_curve_to_playlist`` you just generate the
+Note that by using ``glob_curves_to_playlist`` you just generate the
playlist in the local session. To save your playlist to a file for
future reuse, type::
self._max_loaded = 100 # curves to hold in memory simultaneously.
def append_curve_by_path(self, path, info=None, identify=True):
- if self.path != None:
- path = os.path.join(os.path.dirname(self.path), path)
path = os.path.normpath(path)
c = curve.Curve(path, info=info)
if identify == True:
def __init__(self, drivers, name=None, path=None):
super(FilePlaylist, self).__init__(drivers, name)
+ self.path = None
self.set_path(path)
self._digest = None
self._ignored_keys = [
if self.name == None:
self.name = os.path.basename(path)
+ def append_curve_by_path(self, path, *args, **kwargs):
+ if self.path != None:
+ path = os.path.join(os.path.dirname(self.path), path)
+ super(FilePlaylist, self).append_curve_by_path(path, *args, **kwargs)
+
def is_saved(self):
return self.digest() == self._digest
""".strip())
def playlist_name_callback(hooke, command, argument, value):
+ if value != None:
+ return value
i = 0
names = [p.name for p in hooke.playlists]
while True:
Argument(name='output', type='file',
help="""
File name for the output playlist. Defaults to overwriting the input
-playlist.
+playlist. If the playlist does not have an input file (e.g. it was
+created from scratch with 'new playlist'), this option is required.
""".strip()),
],
help=self.__doc__, plugin=plugin)
"""
from ..command import Command, Argument, Failure
+from ..playlist import FilePlaylist
from ..plugin import Builtin
+from .playlist import PlaylistNameArgument
class PlaylistsPlugin (Builtin):
super(PlaylistsPlugin, self).__init__(name='playlists')
self._commands = [
NextCommand(self), PreviousCommand(self), JumpCommand(self),
- IndexCommand(self), PlaylistListCommand(self)]
+ IndexCommand(self), PlaylistListCommand(self), NewCommand(self)]
# Define commands
def _run(self, hooke, inqueue, outqueue, params):
outqueue.put(list(hooke.playlists))
+
+
+class NewCommand (Command):
+ """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.
+""".strip()),
+ ],
+ 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'],
+ ))
pass
def _on_delete_curve(self, _class, method, playlist, curve):
+ # TODO: execute_command 'remove curve from playlist'
os.remove(curve.path)
def _on_set_selected_playlist(self, _class, method, playlist):