Changeset - fcf9755d9a75
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 18 years ago 2007-03-20 02:39:09
drewp@bigasterisk.com
patch showconfig again
1 file changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/showconfig.py
Show inline comments
 
@@ -24,16 +24,36 @@ def songInMpd(song):
 
    /my/music. song is a file in musicDir; this function returns a
 
    version starting with the mpd path, but minus the mpd root itself.
 
    the mpc ~/.mpdconf
 

	
 
    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")
 

	
 
def songFilename(song):
 
    return path.join(musicDir(),"%s.wav" % song)
0 comments (0 inline, 0 general)