Example #1
0
    def loadCurvesForSong(self):
        """
        current curves will track song's curves.
        
        This fires 'add_curve' dispatcher events to announce the new curves.
        """
        log.info('loadCurvesForSong')
        dispatcher.send("clear_curves")
        self.curveResources.clear()
        self.markers = Markers(uri=None, pointsStorage='file')
        
        self.currentSong = self.graph.value(self.session, L9['currentSong'])
        if self.currentSong is None:
            return

        for uri in sorted(self.graph.objects(self.currentSong, L9['curve'])):
            try:
                cr = self.curveResources[uri] = CurveResource(self.graph, uri)
                cr.loadCurve()

                curvename = self.graph.label(uri)
                if not curvename:
                    raise ValueError("curve %r has no label" % uri)
                dispatcher.send("add_curve", sender=self,
                                uri=uri, label=curvename, curve=cr.curve)
            except Exception as e:
                log.error("loading %s failed: %s", uri, e)
                
        basename = os.path.join(
            showconfig.curvesDir(),
            showconfig.songFilenameFromURI(self.currentSong))
        try:
            self.markers.load("%s.markers" % basename)
        except IOError:
            print "no marker file found"
Example #2
0
def savekey(song, subterms, curveset):
    print "saving", song
    g = createSubtermGraph(song, subterms)
    g.serialize(graphPathForSubterms(song), format="nt")

    curveset.save(basename=os.path.join(showconfig.curvesDir(),
                                        showconfig.songFilenameFromURI(song)))
    print "saved"
Example #3
0
    def save(self):
        """writes a file for each curve with a name
        like basename-curvename, or saves them to the rdf graph"""
        basename=os.path.join(
            showconfig.curvesDir(),
            showconfig.songFilenameFromURI(self.currentSong))

        patches = []
        for cr in self.curveResources.values():
            patches.extend(cr.getSavePatches())

        self.markers.save("%s.markers" % basename)
        # this will cause reloads that will rebuild our curve list
        for p in patches:
            self.graph.patch(p)
Example #4
0
def graphPathForSubterms(song):
    return showconfig.subtermsForSong(showconfig.songFilenameFromURI(song)) + ".n3"