oldest = self._loaded.pop(0)
oldest.unload()
+def playlist_path(path):
+ """Normalize playlist path extensions.
+
+ Examples
+ --------
+ >>> print playlist_path('playlist')
+ playlist.hkp
+ >>> print playlist_path('playlist.hkp')
+ playlist.hkp
+ >>> print playlist_path(None)
+ None
+ """
+ if path == None:
+ return None
+ if not path.endswith('.hkp'):
+ path += '.hkp'
+ return path
+
class FilePlaylist (Playlist):
"""A file-backed :class:`Playlist`.
if self._base_path == None:
self._base_path = os.getcwd()
else:
- if not path.endswith('.hkp'):
- path += '.hkp'
+ path = playlist_path(path)
self.path = path
self._base_path = os.path.dirname(os.path.abspath(
os.path.expanduser(self.path)))
"""
return yaml.load(string)
-def load(path=None, identify=True, hooke=None):
+def load(path=None, drivers=None, identify=True, hooke=None):
"""Load a playlist from a file.
"""
- with open(self.path, 'r') as f:
+ path = playlist_path(path)
+ with open(path, 'r') as f:
text = f.read()
playlist = from_string(text)
+ playlist.set_path(path)
+ print type(playlist)
playlist._digest = playlist.digest()
+ if drivers != None:
+ playlist.drivers = drivers
+ playlist.set_path(path)
for curve in playlist:
curve.set_hooke(hooke)
if identify == True: