From: W. Trevor King Date: Wed, 12 May 2010 18:59:04 +0000 (-0400) Subject: Moved index command from hooke_cli -> hooke.plugin.playlist.IndexCommand. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=178ff1bead612b16e484862c050b8231d162292b;p=hooke.git Moved index command from hooke_cli -> hooke.plugin.playlist.IndexCommand. --- diff --git a/hooke/hooke_cli.py b/hooke/hooke_cli.py index 4a5aca3..d3d19ea 100644 --- a/hooke/hooke_cli.py +++ b/hooke/hooke_cli.py @@ -216,13 +216,3 @@ If the curve is not in the current playlist, it politely asks if we want to add self.do_plot(0) item_not_found=0 - - - def do_index(self,args): - ''' - INDEX - Prints the index of the current curve in the list - ----- - Syntax: index - ''' - print self.pointer+1, 'of', len(self.current_list) diff --git a/hooke/plugin/playlist.py b/hooke/plugin/playlist.py index da2c927..6b16a94 100644 --- a/hooke/plugin/playlist.py +++ b/hooke/plugin/playlist.py @@ -91,6 +91,22 @@ Index of target curve. def _run(self, hooke, inqueue, outqueue, params): params['playlist'].jump(params['index']) +class IndexCommand (Command): + """Print the index of the current curve. + + The first curve has index 0. + """ + def __init__(self): + super(IndexCommand, self).__init__( + name='curve index', + arguments=[ + PlaylistArgument, + ], + help=self.__doc__) + + def _run(self, hooke, inqueue, outqueue, params): + outqueue.put(params['playlist']._index) + class SaveCommand (Command): """Save a playlist. """