Add hooke.playlist.Playlists for better playlist serialization.
authorW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 14:37:21 +0000 (10:37 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 21 Aug 2010 14:37:21 +0000 (10:37 -0400)
hooke/hooke.py
hooke/playlist.py
hooke/plugin/tutorial.py

index 98f364904f4fb0a7ef6cb5f68c0573a4da10e819..d40be70f71753eeb2be74965967fdb440ba8004a 100644 (file)
@@ -92,7 +92,7 @@ class Hooke (object):
         self.load_drivers()
         self.load_ui()
         self.engine = engine.CommandEngine()
-        self.playlists = playlist.NoteIndexList()
+        self.playlists = playlist.Playlists()
 
     def load_log(self):
         config_file = StringIO.StringIO()
index fdebc4042fa01b8b502ebea4053a94d687639b70..473e7362c7b4e722ece4a4788d987e22fd764e44 100644 (file)
@@ -98,8 +98,9 @@ class NoteIndexList (list):
         return state
 
     def _assert_clean_state(self, owner, state):
-        return
         for k,v in state.items():
+            if k == 'drivers':  # HACK.  Need better driver serialization.
+                continue
             try:
                 yaml.safe_dump((k,v))
             except RepresenterError, e:
@@ -520,3 +521,19 @@ class FilePlaylist (Playlist):
             curve.set_hooke(hooke)
             if identify == True:
                 curve.identify(self.drivers)
+
+
+class Playlists (NoteIndexList):
+    """A :class:`NoteIndexList` of :class:`FilePlaylist`\s.
+    """
+    def __init__(self, *arg, **kwargs):
+        super(Playlists, self).__init__(*arg, **kwargs)
+
+    def _item_getstate(self, item):
+        assert isinstance(item, FilePlaylist), type(item)
+        return item.__getstate__()
+
+    def _item_setstate(self, state):
+        item = FilePlaylist(drivers=[])
+        item.__setstate__(state)
+        return item
index 26ef38ea80b98947802859e3a90ac2615c7703d7..ecc9af52d9cb17c7b070309087ca5a0b9b9c7e7f 100644 (file)
@@ -231,9 +231,9 @@ class HookeInfoCommand (Command):
         # loading curves.
         outqueue.put('drivers: %s'
                      % ', '.join([driver.name for driver in hooke.drivers]))
-        # hooke.playlists contains a
-        # :class:`hooke.playlist.NoteIndexList` of
-        # :class:`hooke.playlist.Playlist`\s.  Each playlist may
+        # hooke.playlists is a
+        # :class:`hooke.playlist.Playlists` instance full of
+        # :class:`hooke.playlist.FilePlaylist`\s.  Each playlist may
         # contain several :class:`hooke.curve.Curve`\s representing a
         # grouped collection of data.
         playlist = hooke.playlists.current()