コード例 #1
0
ファイル: notedown.py プロジェクト: tenghaha/mygluon
 def create_outputs(block):
     """Create a set of outputs from the contents of a json code
     block.
     """
     return [
         nbbase.NotebookNode(output)
         for output in json.loads(block['content'])
     ]
コード例 #2
0
ファイル: notedown.py プロジェクト: tenghaha/mygluon
    def create_code_cell(block):
        """Create a notebook code cell from a block."""
        code_cell = nbbase.new_code_cell(source=block['content'])

        attr = block['attributes']
        if not attr.is_empty:
            code_cell.metadata \
                = nbbase.NotebookNode({'attributes': attr.to_dict()})
            execution_count = attr.kvs.get('n')
            if not execution_count:
                code_cell.execution_count = None
            else:
                code_cell.execution_count = int(execution_count)

        return code_cell
コード例 #3
0
    def create_code_cell(block):
        """Create a notebook code cell from a block."""

        # All code should be subslides
        metadata = {'slideshow': {MarkdownPresenterReader.slide_type: MarkdownPresenterReader.SlideTypes.subslide.value}}
        code_cell = nbbase.new_code_cell(source=block['content'], metadata=metadata)

        attr = block['attributes']
        if not attr.is_empty:
            code_cell.metadata.update(nbbase.NotebookNode({'attributes': attr.to_dict()}))
            execution_count = attr.kvs.get('n')
            if not execution_count:
                code_cell.execution_count = None
            else:
                code_cell.execution_count = int(execution_count)

        return code_cell