Moved printlist command from hooke_cli -> hooke.plugin.playlist.CurveListCommand.
authorW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 19:03:17 +0000 (15:03 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 12 May 2010 19:03:17 +0000 (15:03 -0400)
hooke/hooke_cli.py
hooke/plugin/playlist.py

index d3d19eadbb78b89f7f31571f293dd3f7bda52749..1ab299ec49ece30ddd5cceee77193fe9002fa9c9 100644 (file)
@@ -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
index 6b16a9448aeafc58a97c2a6c59990d3fa969fd18..a374e0885c96986a44fc4590fb0c2dca2250370a 100644 (file)
@@ -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.
     """