X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fplaylist.py;h=cd5f9fbd3e37cc01e60dcd121b9a8d9761db0ce4;hp=69442da74fa63033980b942431ca04a3a8b84ae5;hb=328f08fcf7658a22d876ccf0dc7aca0ef9feea64;hpb=e57e6aa9b86351398b3af9a24513169395a71522 diff --git a/hooke/playlist.py b/hooke/playlist.py index 69442da..cd5f9fb 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -91,11 +91,12 @@ class NoteIndexList (list): return self._index return super(NoteIndexList, self).index(value, *args, **kwargs) - def current(self): + def current(self, load=True): if len(self) == 0: return None item = self[self._index] - self._setup_item(item) + if load == True: + self._setup_item(item) return item def jump(self, index): @@ -193,7 +194,7 @@ class Playlist (NoteIndexList): self.append(curve) if curve.driver == None: c.identify(self.drivers) - if curve.data == None: + if curve.data == None or max([d.size for d in curve.data]) == 0: curve.load() self._loaded.append(curve) if len(self._loaded) > self._max_loaded: @@ -201,9 +202,12 @@ class Playlist (NoteIndexList): oldest.unload() def unload(self, curve): - "Inverse of .`_setup_item`." + "Inverse of `._setup_item`." curve.unload() - self._loaded.remove(curve) + try: + self._loaded.remove(curve) + except ValueError: + pass def playlist_path(path): @@ -400,11 +404,13 @@ class FilePlaylist (Playlist): - !!python/object:hooke.engine.CommandMessage arguments: {arg 0: 0, arg 1: X} command: command A + explicit_user_call: true - !!python/object:hooke.engine.CommandMessage arguments: arg 0: 1 curve: *id001 command: command B + explicit_user_call: true info: {attr with spaces: 'The second curve with endlines'} @@ -432,11 +438,13 @@ class FilePlaylist (Playlist): - !!python/object:hooke.engine.CommandMessage arguments: {arg 0: 0, arg 1: X} command: command A + explicit_user_call: true - !!python/object:hooke.engine.CommandMessage arguments: arg 0: 1 curve: *id001 command: command B + explicit_user_call: true info: {attr with spaces: 'The second curve with endlines'} @@ -455,8 +463,10 @@ class FilePlaylist (Playlist): self._relative_curve_paths = self.relative_curve_paths self.update_curve_paths() self._relative_curve_paths = rcp - + digest = self._digest + self._digest = None # don't save the digest (recursive file). yaml_string = yaml.dump(self, allow_unicode=True) + self._digest = digest self.update_curve_paths() return ('# Hooke playlist version %s\n' % self.version) + yaml_string @@ -562,7 +572,7 @@ def from_string(string): def load(path=None, drivers=None, identify=True, hooke=None): """Load a playlist from a file. """ - path = playlist_path(path) + path = os.path.expanduser(playlist_path(path)) with open(path, 'r') as f: text = f.read() playlist = from_string(text)