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"
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"
def pointsFromGraph(self): pts = self.graph.value(self.uri, L9['points']) if pts is not None: self.curve.set_from_string(pts) else: diskPts = self.graph.value(self.uri, L9['pointsFile']) if diskPts is not None: self.curve.load(os.path.join(showconfig.curvesDir(), diskPts)) else: log.warn("curve %s has no points", self.uri) self.watchCurvePointChanges()
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)