def nb_to_rst(nb_path):
    exporter = rst.RSTExporter()
    out, resources = exporter.from_file(open(nb_path))
    basename = os.path.splitext(os.path.basename(nb_path))[0]
    imgdir = basename + '_files'
    img_prefix = os.path.join(imgdir, basename + '_')
    resources['metadata']['basename'] = basename
    resources['metadata']['name'] = basename.replace('_', ' ')
    resources['metadata']['imgdir'] = imgdir
    base_url = ('http://nbviewer.ipython.org/github/Unidata/siphon/blob/master/'
                'examples/notebooks/')
    out_lines = ['`Notebook <%s>`_' % (base_url + os.path.basename(nb_path))]
    for line in out.split('\n'):
        if line.startswith('.. image:: '):
            line = line.replace('output_', img_prefix)
        out_lines.append(line)
    out = '\n'.join(out_lines)

    return out, resources
Create Reg predicates.
dataset/ETHPy150Open Unidata/siphon/docs/source/notebook_gen_sphinxext.py/nb_to_rst--crossover with--dataset/ETHPy150Open morepath/morepath/morepath/predicate.py/PredicateRegistry.get_predicates