Added hooke.util.yaml fixing YAML/NumPy type issues (by dropping data).
[hooke.git] / hooke / playlist.py
index 473e7362c7b4e722ece4a4788d987e22fd764e44..3380bfcacfc4ca24a02f4ee49e11c89370fa9cd0 100644 (file)
@@ -102,11 +102,11 @@ class NoteIndexList (list):
             if k == 'drivers':  # HACK.  Need better driver serialization.
                 continue
             try:
-                yaml.safe_dump((k,v))
+                yaml.dump((k,v))
             except RepresenterError, e:
                 raise NotImplementedError(
-                    'cannot convert %s.%s = %s (%s) to safe YAML'
-                    % (owner.__class__.__name__, k, v, type(v)))
+                    'cannot convert %s.%s = %s (%s) to YAML\n%s'
+                    % (owner.__class__.__name__, k, v, type(v), e))
 
     def _setup_item(self, item):
         """Perform any required initialization before returning an item.
@@ -197,10 +197,9 @@ class Playlist (NoteIndexList):
         self._ignored_attrs.extend([
                 '_item_ignored_attrs', '_item_default_attrs',
                 '_loaded'])
-        self._item_ignored_attrs = []
+        self._item_ignored_attrs = ['data']
         self._item_default_attrs = {
             'command_stack': [],
-            'data': None,
             'driver': None,
             'info': {},
             'name': None,
@@ -383,11 +382,14 @@ class FilePlaylist (Playlist):
         - info: {note: The first curve}
           name: one
           path: curve/one
-        - command_stack:
-          - arguments: {arg 0: 0, arg 1: X}
-            command: command A
-          - arguments: {arg 0: 1, arg 1: Y}
-            command: command B
+        - command_stack: !!python/object/new:hooke.command_stack.CommandStack
+            listitems:
+            - !!python/object:hooke.engine.CommandMessage
+              arguments: {arg 0: 0, arg 1: X}
+              command: command A
+            - !!python/object:hooke.engine.CommandMessage
+              arguments: {arg 0: 1, arg 1: Y}
+              command: command B
           info: {attr with spaces: 'The second curve
         <BLANKLINE>
               with endlines'}
@@ -410,11 +412,14 @@ class FilePlaylist (Playlist):
         - info: {note: The first curve}
           name: one
           path: /path/to/curve/one
-        - command_stack:
-          - arguments: {arg 0: 0, arg 1: X}
-            command: command A
-          - arguments: {arg 0: 1, arg 1: Y}
-            command: command B
+        - command_stack: !!python/object/new:hooke.command_stack.CommandStack
+            listitems:
+            - !!python/object:hooke.engine.CommandMessage
+              arguments: {arg 0: 0, arg 1: X}
+              command: command A
+            - !!python/object:hooke.engine.CommandMessage
+              arguments: {arg 0: 1, arg 1: Y}
+              command: command B
           info: {attr with spaces: 'The second curve
         <BLANKLINE>
               with endlines'}
@@ -462,11 +467,14 @@ class FilePlaylist (Playlist):
         ... items:
         ... - info: {note: The first curve}
         ...   path: curve/one
-        ... - command_stack:
-        ...   - arguments: {arg 0: 0, arg 1: X}
-        ...     command: command A
-        ...   - arguments: {arg 0: 1, arg 1: Y}
-        ...     command: command B
+        ... - command_stack: !!python/object/new:hooke.command_stack.CommandStack
+        ...      listitems:
+        ...      - !!python/object:hooke.engine.CommandMessage
+        ...        arguments: {arg 0: 0, arg 1: X}
+        ...        command: command A
+        ...      - !!python/object:hooke.engine.CommandMessage
+        ...        arguments: {arg 0: 1, arg 1: Y}
+        ...        command: command B
         ...   info: {attr with spaces: 'The second curve
         ... 
         ...       with endlines'}