예제 #1
0
def ipynb2py(filename):
    py_source = py_exporter.from_file(filename)[0]
    py_filename = filename.replace('.ipynb', '.py')
    with open(py_filename, 'w') as fout:
        fout.write(py_source)
    return py_filename


def get_cell_labels_from_html(html_source):
    soup = BeautifulSoup(html_source)
    cells = soup.find_all("div", class_="inner_cell")
    stages = []
    for cell in cells:
        labeled_option = cell.find('option', {'selected': True})
        # stage = labeled_option["value"]
        stages.append(labeled_option["value"])
        # pdb.set_trace()
    return stages

    # raise NotImplementedError


if __name__ == '__main__':
    # print(DECISION_POINTS)
    py_source = py_exporter.from_file(
        '/projects/bdata/jupyter/_7_1/nb_1166597.ipynb')[0]
    cells = cut_cells_from_py_source(py_source)
    pdb.set_trace()
    cells = cut_cells_from_py('/projects/bdata/jupyter/_7_1/nb_1166597.ipynb')