c._index = 0
return c
+
class Playlist (NoteIndexList):
"""A :class:`NoteIndexList` of :class:`hooke.curve.Curve`\s.
self.drivers = drivers
self._loaded = [] # List of loaded curves, see :meth:`._setup_item`.
self._max_loaded = 100 # curves to hold in memory simultaneously.
+ self._curve_load_args = ()
+ self._curve_load_kwargs = {}
def append_curve_by_path(self, path, info=None, identify=True):
path = os.path.normpath(path)
self.append(c)
return c
+ def set_curve_load_args(self, *args, **kwargs):
+ self._curve_load_args = args
+ self._curve_load_kwargs = kwargs
+
def _setup_item(self, curve):
if curve != None and curve not in self._loaded:
if curve not in self:
if curve.driver == None:
c.identify(self.drivers)
if curve.data == None:
- curve.load()
+ curve.load(*self._curve_load_args, **self._curve_load_kwargs)
self._loaded.append(curve)
if len(self._loaded) > self._max_loaded:
oldest = self._loaded.pop(0)
oldest.unload()
+
class FilePlaylist (Playlist):
version = '0.1'
"""Saves the playlist in a XML file.
"""
self.set_path(path)
- f = file(self.path, 'w')
- f.write(self.flatten())
- f.close()
+ with open(self.path, 'w') as f:
+ f.write(self.flatten())
+ self._digest = self.digest()