Mercurial > code > home > repos > light9
changeset 318:fcf9755d9a75
patch showconfig again
author | drewp@bigasterisk.com |
---|---|
date | Tue, 20 Mar 2007 02:39:09 +0000 |
parents | 1bd15c2c9d47 |
children | 2193eab0650b |
files | light9/showconfig.py |
diffstat | 1 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/showconfig.py Fri Jun 16 17:06:38 2006 +0000 +++ b/light9/showconfig.py Tue Mar 20 02:39:09 2007 +0000 @@ -27,10 +27,30 @@ changed root to /home/drewp/projects/light9/show/dance2005 for now """ - - if 'dance2005' in root(): - return "projects/dance2005/%s" % song - raise NotImplementedError + + assert isinstance(song, URIRef), "songInMpd now takes URIRefs" + + mpdHome = None + for line in open(path.expanduser("~/.mpdconf")): + if line.startswith("music_directory"): + mpdHome = line.split()[1].strip('"') + if mpdHome is None: + raise ValueError("can't find music_directory in your ~/.mpdconf") + mpdHome = mpdHome.rstrip(path.sep) + path.sep + + songFullPath = songOnDisk(song) + if not songFullPath.startswith(mpdHome): + raise ValueError("the song path %r is not under your MPD music_directory (%r)" % (songFullPath, mpdHome)) + + mpdRelativePath = songFullPath[len(mpdHome):] + if path.join(mpdHome, mpdRelativePath) != songFullPath: + raise ValueError("%r + %r doesn't make the songpath %r" % (mpdHome, mpdRelativePath, songFullPath)) + return mpdRelativePath.encode('ascii') + +def songOnDisk(song): + graph = getGraph() + songFullPath = path.join(root(), graph.value(song, L9['showPath'])) + return songFullPath def curvesDir(): return path.join(root(),"curves")