Add test/note.py and adjust playlist handling so NoteFilterCommand works again.
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 01:07:30 +0000 (21:07 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 01:07:30 +0000 (21:07 -0400)
hooke/playlist.py
hooke/plugin/playlist.py
test/note.py [new file with mode: 0644]

index ee586095e4a5795144f9fe1ec886ae23b939bda8..cdde7ba2e899a17b4ee195bb3e50f8e3d8913e6d 100644 (file)
@@ -30,6 +30,7 @@ import xml.dom.minidom
 
 from . import curve as curve
 from .compat import minidom as minidom  # dynamically patch xml.sax.minidom
+from .util.itertools import reverse_enumerate
 
 
 class NoteIndexList (list):
@@ -102,7 +103,7 @@ class NoteIndexList (list):
         index = self._index
         items = self
         if reverse == True:
-            items = reversed(enumerate(self))
+            items = reverse_enumerate(self)
         else:
             items = enumerate(self)
         for i,item in items:
index 1439ba63d7e0b6b4b46bca1591d68aa4069da820..53fc28ae5928a2388222796a860051d0a22546ba 100644 (file)
@@ -400,8 +400,7 @@ Function returning `True` for "good" curves.
             filter_fn = self.filter
         p = self._playlist(hooke, params).filter(filter_fn,
             hooke=hooke, inqueue=inqueue, outqueue=outqueue, params=params)
-        p.name = params['name']
+        self._set_playlist(hooke, params, p)
         if hasattr(p, 'path') and p.path != None:
             p.set_path(os.path.join(os.path.dirname(p.path), p.name))
-        self._set_playlist(hooke, params, p)
         outqueue.put(p)
diff --git a/test/note.py b/test/note.py
new file mode 100644 (file)
index 0000000..ccff85d
--- /dev/null
@@ -0,0 +1,94 @@
+# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+"""
+>>> from hooke.hooke import Hooke, HookeRunner
+>>> h = Hooke()
+>>> r = HookeRunner()
+
+>>> h = r.run_lines(h, ['new_playlist --output_playlist mylist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*']
+...     )  # doctest: +ELLIPSIS
+<Curve 0x06130001>
+<Curve 0x07200000>
+<Curve 20071120a_i27_t33.100>
+<Curve 20071120a_i27_t33.101>
+...
+<Curve 20071120a_i27_t33.199>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_curve 14'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['''set_note "Hi there.\\nI'm a note"'''])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_curve 27'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['''set_note "I'm another note."'''])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['note_filter_playlist --output_playlist filtered'])
+<FilePlaylist filtered>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist mylist>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist filtered>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 20071120a_i27_t33.112>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_curve -- -1'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 20071120a_i27_t33.125>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+1
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_note'])
+I'm another note.
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['set_note ""'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_note'])
+None
+Success
+<BLANKLINE>
+"""