def publish(source, target, profile, login): """Publish the notebook for globally viewable interactive plots """ regex = r"(ILinePlot|EventPlot)\.generate\(\'(fig_.{32})\', '\/(nbextensions|static)\/'\)" txt = "" with open(source, 'r') as file_fh: for line in file_fh: match = re.search(regex, line) if match: plot = match.group(1) fig = match.group(2) logging.info("Publishing %s : %s", plot, fig) line = re.sub( regex, plot + ".generate('" + fig + "', '" + create_new_gist(fig, profile, login) + "')", line) txt += line txt = change_resource_paths(txt) with open(target, 'w') as file_fh: file_fh.write(txt) trust = TrustNotebookApp() trust.sign_notebook(target) logging.info("Signed and Saved: %s", target)
def publish(source, target): """Publish the notebook for globally viewable interactive plots """ txt = "" with open(source, 'r') as file_fh: txt = change_resource_paths(file_fh.read()) with open(target, 'w') as file_fh: file_fh.write(txt) trust = TrustNotebookApp() trust.sign_notebook(target) logging.info("Signed and Saved: %s", target)