From: W. Trevor King Date: Wed, 12 May 2010 19:03:17 +0000 (-0400) Subject: Moved printlist command from hooke_cli -> hooke.plugin.playlist.CurveListCommand. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d72a56793bf058b2a8ee735ac67c1b7ecaa7819a;p=hooke.git Moved printlist command from hooke_cli -> hooke.plugin.playlist.CurveListCommand. --- diff --git a/hooke/hooke_cli.py b/hooke/hooke_cli.py index d3d19ea..1ab299e 100644 --- a/hooke/hooke_cli.py +++ b/hooke/hooke_cli.py @@ -156,63 +156,3 @@ Syntax: set [variable] [value] self.config[key]=value self.do_plot(0) - - def help_printlist(self): - print ''' -PRINTLIST -Prints the list of curves in the current playlist -------------- -Syntax: printlist -''' - def do_printlist(self,args): - for item in self.current_list: - print item.path - - - def help_jump(self): - print ''' -JUMP -Jumps to a given curve. ------- -Syntax: jump {$curve} - -If the curve is not in the current playlist, it politely asks if we want to add it. - ''' - def do_jump(self,filename): - ''' - jumps to the curve with the given filename. - if the filename is not in the playlist, it asks if we must add it or not. - ''' - - if filename=='': - filename=linp.safeinput('Jump to?') - - filepath=os.path.abspath(filename) - print filepath - - c=0 - item_not_found=1 - while item_not_found: - try: - - if self.current_list[c].path == filepath: - self.pointer=c - self.current=self.current_list[self.pointer] - item_not_found=0 - self.do_plot(0) - else: - c+=1 - except IndexError: - #We've found the end of the list. - answer=linp.safeinput('Curve not found in playlist. Add it to list?',['y']) - if answer.lower()[0]=='y': - try: - self.do_addtolist(filepath) - except: - print 'Curve file not found.' - return - self.current=self.current_list[-1] - self.pointer=(len(current_list)-1) - self.do_plot(0) - - item_not_found=0 diff --git a/hooke/plugin/playlist.py b/hooke/plugin/playlist.py index 6b16a94..a374e08 100644 --- a/hooke/plugin/playlist.py +++ b/hooke/plugin/playlist.py @@ -16,6 +16,7 @@ class PlaylistPlugin (Builtin): def commands(self): return [NextCommand(), PreviousCommand(), JumpCommand(), + IndexCommand(), CurveListCommand(), SaveCommand(), LoadCommand(), AddCommand(), AddGlobCommand(), RemoveCommand(), FilterCommand(), NoteFilterCommand()] @@ -107,6 +108,20 @@ class IndexCommand (Command): def _run(self, hooke, inqueue, outqueue, params): outqueue.put(params['playlist']._index) +class CurveListCommand (Command): + """Get the curves in a playlist. + """ + def __init__(self): + super(CurveListCommand, self).__init__( + name='playlist curves', + arguments=[ + PlaylistArgument, + ], + help=self.__doc__) + + def _run(self, hooke, inqueue, outqueue, params): + outqueue.put([c for c in params['playlist']]) + class SaveCommand (Command): """Save a playlist. """