Files
@ ca37e8fe9a1b
Branch filter:
Location: light9/light9/showconfig.py - annotation
ca37e8fe9a1b
4.4 KiB
text/x-python
demo data for 2014 show
Ignore-this: 294e31383915ea01b210e0a8afa38aa0
Ignore-this: 294e31383915ea01b210e0a8afa38aa0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 231a8b3aedc3 231a8b3aedc3 c6aabf5bd3bc a301a0039c66 5f9cf6174e62 5f9cf6174e62 1929e0e1053e 5f9cf6174e62 231a8b3aedc3 5f9cf6174e62 231a8b3aedc3 231a8b3aedc3 c6aabf5bd3bc 231a8b3aedc3 231a8b3aedc3 f6c73fafffe9 231a8b3aedc3 231a8b3aedc3 231a8b3aedc3 231a8b3aedc3 21b458127924 21b458127924 21b458127924 21b458127924 13c089886f61 13c089886f61 21b458127924 21b458127924 94039df5cdd9 94039df5cdd9 bc0bd8ad8ba9 94039df5cdd9 d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c a60a73463ef0 a60a73463ef0 d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c d4284e68e51c fcf9755d9a75 2b2f5da47c5d fcf9755d9a75 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 98ec0fbbe980 d8202a0a7fd5 13c089886f61 7771f37252da 7771f37252da 7771f37252da 7771f37252da 7771f37252da 7771f37252da 7771f37252da 7771f37252da 7771f37252da 94039df5cdd9 94039df5cdd9 94039df5cdd9 94039df5cdd9 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 08814a44ae4e 1627032629dc 1627032629dc 94039df5cdd9 94039df5cdd9 94039df5cdd9 21b458127924 21b458127924 21b458127924 21b458127924 7771f37252da 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 21b458127924 c7797ad42684 5f9cf6174e62 5f9cf6174e62 5f9cf6174e62 | import time, logging, warnings
from twisted.python.filepath import FilePath
from os import path, getenv
from rdflib import Graph
from rdflib import URIRef
from namespaces import MUS, L9
log = logging.getLogger('showconfig')
_config = None # graph
def getGraph():
warnings.warn("code that's using showconfig.getGraph should be "
"converted to use the sync graph", stacklevel=2)
global _config
if _config is None:
graph = Graph()
for f in FilePath(root()).globChildren("*.n3") + FilePath(root()).globChildren("build/*.n3"):
log.info("reading %s", f)
graph.parse(location=f.path, format='n3')
_config = graph
return _config
def root():
r = getenv("LIGHT9_SHOW")
if r is None:
raise OSError(
"LIGHT9_SHOW env variable has not been set to the show root")
return r
def showUri():
"""Return the show URI associated with $LIGHT9_SHOW."""
return URIRef(file(path.join(root(), 'URI')).read().strip())
def findMpdHome():
"""top of the music directory for the mpd on this system,
including trailing slash"""
mpdHome = None
for mpdConfFilename in ["/my/dl/modified/mpd/src/mpdconf-testing",
"~/.mpdconf", "/etc/mpd.conf"]:
try:
mpdConfFile = open(path.expanduser(mpdConfFilename))
except IOError:
continue
for line in mpdConfFile:
if line.startswith("music_directory"):
mpdHome = line.split()[1].strip('"')
return mpdHome.rstrip(path.sep) + path.sep
raise ValueError("can't find music_directory in any mpd config file")
def songOnDisk(song):
"""given a song URI, where's the on-disk file that mpd would read?"""
graph = getGraph()
root = graph.value(showUri(), L9['musicRoot'])
if not root:
raise ValueError("%s has no :musicRoot" % showUri())
name = graph.value(song, L9['songFilename'])
if not name:
raise ValueError("Song %r has no :songFilename" % song)
return path.abspath(path.join(root, name))
def songFilenameFromURI(uri):
"""
'http://light9.bigasterisk.com/show/dance2007/song8' -> 'song8'
everything that uses this should be deprecated for real URIs
everywhere"""
assert isinstance(uri, URIRef)
return uri.split('/')[-1]
def getSongsFromShow(graph, show):
playList = graph.value(show, L9['playList'])
if not playList:
raise ValueError("%r has no l9:playList" % show)
songs = [
# this was graph.items(playlistUri) but i was getting other
# items from a totally different list! seems like bnode
# corruption.
URIRef("http://light9.bigasterisk.com/show/dance2013/song1"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song2"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song3"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song4"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song5"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song6"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song7"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song8"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song9"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song10"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song11"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song12"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song13"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song14"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song15"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song16"),
URIRef("http://light9.bigasterisk.com/show/dance2013/song17"),
]
# probably fixed with the patch in https://github.com/RDFLib/rdflib/issues/305
#songs = list(graph.items(playList))
return songs
def curvesDir():
return path.join(root(),"curves")
def songFilename(song):
return path.join(root(), "music", "%s.wav" % song)
def subtermsForSong(song):
return path.join(root(),"subterms",song)
def subFile(subname):
return path.join(root(),"subs",subname)
def subsDir():
return path.join(root(),'subs')
def prePostSong():
graph = getGraph()
return [graph.value(MUS['preSong'], L9['showPath']),
graph.value(MUS['postSong'], L9['showPath'])]
|