Move NoteFilterCommand from plugin.playlist to plugin.note.
[hooke.git] / hooke / plugin / note.py
index b36c8013c84962e9c02fffa690d034d632bcccd4..b982075daa17cab895d8a63204b9d1d6a25417d9 100644 (file)
 """
 
 from ..command import Command, Argument, Failure
-from ..plugin import Builtin
-from ..plugin.curve import current_curve_callback
-
+from . import Builtin
+from .curve import current_curve_callback
+from .playlist import FilterCommand
 
 class NotePlugin (Builtin):
     def __init__(self):
         super(NotePlugin, self).__init__(name='note')
         self._commands = [
-            SetNoteCommand(self), GetNoteCommand(self)]
+            SetNoteCommand(self), GetNoteCommand(self),
+            NoteFilterCommand(self),
+            ]
 
 
 class SetNoteCommand (Command):
-    """Add a note to one of several Hooke objects.
+    """Set the note on one of several Hooke objects.
     """
     def __init__(self, plugin):
         super(SetNoteCommand, self).__init__(
@@ -59,7 +61,7 @@ The note text.
 
 
 class GetNoteCommand (Command):
-    """Retrieve notes from one of several Hooke objects.
+    """Retrieve the note from one of several Hooke objects.
     """
     def __init__(self, plugin):
         super(GetNoteCommand, self).__init__(
@@ -76,3 +78,14 @@ Target object for the note.  Defaults to the current curve.
 
     def _run(self, hooke, inqueue, outqueue, params):
         outqueue.put(params['target'].info['note'])
+
+
+class NoteFilterCommand (FilterCommand):
+    """Create a subset playlist of curves with `.info['note'] != None`.
+    """
+    def __init__(self, plugin):
+        super(NoteFilterCommand, self).__init__(
+            plugin, name='note filter playlist')
+
+    def filter(self, curve, hooke, inqueue, outqueue, params):
+        return 'note' in curve.info and curve.info['note'] != None