Ran update_copyright.py.
[hooke.git] / hooke / plugin / note.py
index eebf8c6368f2f48d6d95422110a35a7b4e3e7cb7..3913149823c57dde706f1816e9d454d6ea6cf7c4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
 #
 # This file is part of Hooke.
 #
 """
 
 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):
@@ -75,4 +77,15 @@ Target object for the note.  Defaults to the current curve.
             help=self.__doc__, plugin=plugin)
 
     def _run(self, hooke, inqueue, outqueue, params):
-        outqueue.put(params['target'].info['note'])
+        outqueue.put(params['target'].info.get('note', None))
+
+
+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', load_curves=False)
+
+    def filter(self, curve, hooke, inqueue, outqueue, params):
+        return 'note' in curve.info and curve.info['note'] != None