From: W. Trevor King Date: Tue, 17 Aug 2010 01:07:30 +0000 (-0400) Subject: Add test/note.py and adjust playlist handling so NoteFilterCommand works again. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2829775e565af5f5f1323d9ca5b9e5a14fb3485b;p=hooke.git Add test/note.py and adjust playlist handling so NoteFilterCommand works again. --- diff --git a/hooke/playlist.py b/hooke/playlist.py index ee58609..cdde7ba 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -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: diff --git a/hooke/plugin/playlist.py b/hooke/plugin/playlist.py index 1439ba6..53fc28a 100644 --- a/hooke/plugin/playlist.py +++ b/hooke/plugin/playlist.py @@ -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 index 0000000..ccff85d --- /dev/null +++ b/test/note.py @@ -0,0 +1,94 @@ +# Copyright (C) 2010 W. Trevor King +# +# 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 +# . + +""" +>>> from hooke.hooke import Hooke, HookeRunner +>>> h = Hooke() +>>> r = HookeRunner() + +>>> h = r.run_lines(h, ['new_playlist --output_playlist mylist']) +Success + +>>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*'] +... ) # doctest: +ELLIPSIS + + + + +... + +Success + +>>> h = r.run_lines(h, ['jump_to_curve 14']) +Success + +>>> h = r.run_lines(h, ['''set_note "Hi there.\\nI'm a note"''']) +Success + +>>> h = r.run_lines(h, ['jump_to_curve 27']) +Success + +>>> h = r.run_lines(h, ['''set_note "I'm another note."''']) +Success + +>>> h = r.run_lines(h, ['note_filter_playlist --output_playlist filtered']) + +Success + +>>> h = r.run_lines(h, ['get_playlist']) + +Success + +>>> h = r.run_lines(h, ['jump_to_playlist -- -1']) +Success + +>>> h = r.run_lines(h, ['get_playlist']) + +Success + +>>> h = r.run_lines(h, ['get_curve']) + +Success + +>>> h = r.run_lines(h, ['curve_index']) +0 +Success + +>>> h = r.run_lines(h, ['jump_to_curve -- -1']) +Success + +>>> h = r.run_lines(h, ['get_curve']) + +Success + +>>> h = r.run_lines(h, ['curve_index']) +1 +Success + +>>> h = r.run_lines(h, ['get_note']) +I'm another note. +Success + +>>> h = r.run_lines(h, ['set_note ""']) +Success + +>>> h = r.run_lines(h, ['get_note']) +None +Success + +"""