Пример #1
0
def test_notebook(name):
    """
    Make a test notebook for the given name.
    """
    nb = new_notebook()
    nb.cells.append(new_code_cell("'code_' + '{}'".format(name)))
    nb.cells.append(new_raw_cell("raw_{}".format(name)))
    nb.cells.append(new_markdown_cell('markdown_{}'.format(name)))
    return nb
Пример #2
0
# -*- coding: utf-8 -*-
import os
from base64 import encodestring

from IPython.nbformat.v4.nbbase import (
    new_code_cell, new_markdown_cell, new_notebook,
    new_output, new_raw_cell
)

# some random base64-encoded *text*
png = encodestring(os.urandom(5)).decode('ascii')
jpeg = encodestring(os.urandom(6)).decode('ascii')

cells = []
cells.append(new_markdown_cell(
    source='Some NumPy Examples',
))


cells.append(new_code_cell(
    source='import numpy',
    execution_count=1,
))

cells.append(new_markdown_cell(
    source='A random array',
))

cells.append(new_raw_cell(
    source='A random array',
))
Пример #3
0
 def create_markdown_cell(block):
     """Create a markdown cell from a block."""
     kwargs = {'cell_type': block['type'],
               'source': block['content']}
     markdown_cell = nbbase.new_markdown_cell(**kwargs)
     return markdown_cell
Пример #4
0
 def create_markdown_cell(block):
     """Create a markdown cell from a block."""
     kwargs = {'cell_type': block['type'],
               'source': block['content']}
     markdown_cell = nbbase.new_markdown_cell(**kwargs)
     return markdown_cell