From 2edbfa63892a8357b7dc8386cd10ab390646c131 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 9 Nov 2011 14:55:10 -0500 Subject: [PATCH] Standardize playlist path expansion in hooke/playlist.py. --- hooke/playlist.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hooke/playlist.py b/hooke/playlist.py index c89298e..f323ca2 100644 --- a/hooke/playlist.py +++ b/hooke/playlist.py @@ -213,7 +213,7 @@ class Playlist (NoteIndexList): pass -def playlist_path(path): +def playlist_path(path, expand=False): """Normalize playlist path extensions. Examples @@ -229,6 +229,8 @@ def playlist_path(path): return None if not path.endswith('.hkp'): path += '.hkp' + if expand: + path = os.path.abspath(os.path.expanduser(path)) return path @@ -302,10 +304,9 @@ class FilePlaylist (Playlist): if self._base_path == None: self._base_path = os.getcwd() else: - path = playlist_path(path) + path = playlist_path(path, expand=True) self.path = path - self._base_path = os.path.dirname(os.path.abspath( - os.path.expanduser(self.path))) + self._base_path = os.path.dirname(self.path) if self.name == None: self.name = os.path.basename(path) if self._base_path != orig_base_path: @@ -575,7 +576,7 @@ def from_string(string): def load(path=None, drivers=None, identify=True, hooke=None): """Load a playlist from a file. """ - path = os.path.expanduser(playlist_path(path)) + path = playlist_path(path, expand=True) with open(path, 'r') as f: text = f.read() playlist = from_string(text) -- 2.26.2