X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fplaylist.py;h=b996a5f7777c460de74268c528e1897c4e7a7eb2;hp=9ee31259f780e633eb0a25afc0148bd46a244901;hb=4c842e06a1187f043fee396f3d39081f34317521;hpb=f96f6bdf5bc2bab0a2f527eb87de37e17dc1b96f diff --git a/hooke/playlist.py b/hooke/playlist.py index 9ee3125..b996a5f 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -27,6 +27,24 @@ import os import os.path import types +if False: # YAML dump debugging code + """To help isolate data types etc. that give YAML problems. + + This is usually caused by external C modules (e.g. numpy) that + define new types (e.g. numpy.dtype) which YAML cannot inspect. + """ + import yaml.representer + import sys + def ignore_aliases(data): + print data, type(data) + sys.stdout.flush() + if data in [None, ()]: + return True + if isinstance(data, (str, unicode, bool, int, float)): + return True + yaml.representer.SafeRepresenter.ignore_aliases = staticmethod( + ignore_aliases) + import yaml from yaml.representer import RepresenterError @@ -103,10 +121,10 @@ class NoteIndexList (list): continue try: yaml.dump((k,v)) - except (TypeError, RepresenterError), e: + except RepresenterError, e: raise NotImplementedError( - 'cannot convert %s.%s = %s (%s) to 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 +215,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,