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 98f3649..d40be70 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 fdebc40..473e736 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 26ef38e..ecc9af5 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()