def __doTransform(self): """Do the work.""" uri = fixUri(self.uri) # Get template tplFile = getTemplate(self.uri) if not tplFile: print "Could not find matching template file for the URI." print "Uri was %s" % self.uri return False # TODO: Temp fix trypath = "./" + tplFile if exists(trypath): tplFile = trypath else: tplFile = "./web2rdf/" + tplFile self.webTransform = WebTransform(self.uri) # Web Cache logic cachef = CacheMap(self.uri) if not cachef.exists() or cachef.isExpired(): self.webTransform.download() self.webTransform.saveHtml(cachef.getCacheFilename()) else: self.webTransform.load(cachef.getCacheFilename()) # Convert & save result self.webTransform.convertWithXslt(tplFile)
def saveRdf(self, filename = None): """Saves the RDF to a file""" if not self.webTransform: self.__doTransform() if not self.webTransform: return False if not filename: cachef = CacheMap(self.uri) filename = cachef.getCacheFilename() + ".cache.rdf" print "Saving to %s. " % filename self.webTransform.saveRdf(filename)