def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = DownloadMagic(kernel)
    # Make magics callable:
    kernel.line_magics["download"] = magic

    @register_line_magic
    def download(line):
        kernel.call_magic("%download " + line)
Esempio n. 2
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = Prompt4VarMagic(kernel)
    # Make magics callable:
    kernel.line_magics["prompt4var"] = magic

    @register_line_magic
    def prompt4var(line):
        kernel.call_magic("%prompt4var " + line)
Esempio n. 3
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = DownloadMagic(kernel)
    # Make magics callable:
    kernel.line_magics["download"] = magic

    @register_line_magic
    def download(line):
        kernel.call_magic("%download " + line)
Esempio n. 4
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = Prompt4VarMagic(kernel)
    # Make magics callable:
    kernel.line_magics["prompt4var"] = magic

    @register_line_magic
    def prompt4var(line):
        kernel.call_magic("%prompt4var " + line)
Esempio n. 5
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = JigsawMagic(kernel)
    # Make magics callable:
    kernel.line_magics["jigsaw"] = magic

    @register_line_magic
    def jigsaw(line):
        """
        Use the Jigsaw code visualizer and generator.
        """
        kernel.call_magic("%jigsaw " + line)
Esempio n. 6
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = JigsawMagic(kernel)
    # Make magics callable:
    kernel.line_magics["jigsaw"] = magic

    @register_line_magic
    def jigsaw(line):
        """
        Use the Jigsaw code visualizer and generator.
        """
        kernel.call_magic("%jigsaw " + line)
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = BlocklyMagic(kernel)
    # Make magics callable:
    kernel.line_magics["blockly"] = magic

    @register_line_magic
    def blockly(line):
        """
        Use the blockly code visualizer and generator.
        """
        kernel.call_magic("%blockly " + line)
Esempio n. 8
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = DotMagic(kernel)
    # Make magics callable:
    kernel.cell_magics["dot"] = magic

    @register_cell_magic
    def dot(line, cell):
        """
        %%dot - evaluate cell contents as a dot diagram.
        """
        magic.code = cell
        kernel.call_magic(line)
Esempio n. 9
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = DotMagic(kernel)
    # Make magics callable:
    kernel.cell_magics["dot"] = magic

    @register_cell_magic
    def dot(line, cell):
        """
        %%dot - evaluate cell contents as a dot diagram.
        """
        magic.code = cell
        kernel.call_magic(line)
Esempio n. 10
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic
    kernel = IPythonKernel()
    magic = logMagic(kernel)
    # Make magics callable:
    kernel.line_magics["showLog"] = magic
    kernel.line_magics["showFullLog"] = magic

    @register_line_magic
    def showLog(line):
        kernel.call_magic("%showLog " + line)

    @register_line_magic
    def showFullLog(line):
        kernel.call_magic("%showFullLog " + line)
Esempio n. 11
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic, register_cell_magic
    kernel = IPythonKernel()
    magic = KernelMagic(kernel)

    @register_line_magic
    def kernel(line):
        """
        line is module_name, class_name[, kernel_name]
        """
        if line.strip().count(" ") == 1:
            kernel_name = "default"
            module_name, class_name = [
                item.strip() for item in line.strip().split(" ", 1)
            ]
        else:
            module_name, class_name, kernel_name = [
                item.strip() for item in line.strip().split(" ", 2)
            ]
        magic.line_kernel(module_name, class_name, kernel_name)

    @register_cell_magic
    def kx(line, cell):
        """
        line is kernel_name, or "default"
        """
        if line.strip():
            module_name = line.strip()
        else:
            module_name = "default"
        magic.code = cell
        magic.cell_kx(module_name)
Esempio n. 12
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = SimulationMagic(kernel)

    @register_cell_magic
    def simulation(line, cell):
        magic.code = cell
        magic.cell_simulation()
Esempio n. 13
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from metakernel.utils import add_docs
    from IPython.core.magic import register_line_magic, register_cell_magic
    kernel = IPythonKernel()
    magic = ActivityMagic(kernel)
    # Make magics callable:
    kernel.line_magics["activity"] = magic
    kernel.cell_magics["activity"] = magic

    @register_line_magic
    @add_docs(magic.line_activity.__doc__)
    def activity(line):
        kernel.call_magic("%activity " + line)

    @register_cell_magic
    @add_docs(magic.cell_activity.__doc__)
    def activity(line, cell):
        magic.code = cell
        magic.cell_activity(line)
Esempio n. 14
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from metakernel.utils import add_docs
    from IPython.core.magic import register_line_magic, register_cell_magic
    kernel = IPythonKernel()
    magic = ActivityMagic(kernel)
    # Make magics callable:
    kernel.line_magics["activity"] = magic
    kernel.cell_magics["activity"] = magic

    @register_line_magic
    @add_docs(magic.line_activity.__doc__)
    def activity(line):
        kernel.call_magic("%activity " + line)

    @register_cell_magic
    @add_docs(magic.cell_activity.__doc__)
    def activity(line, cell):
        magic.code = cell
        magic.cell_activity(line)
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = ProcessingMagic(kernel)

    @register_cell_magic
    def processing(line, cell):
        """
        """
        magic.code = cell
        magic.cell_processing()
Esempio n. 16
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = DotMagic(kernel)

    @register_cell_magic
    def dot(line, cell):
        """
        %%dot - evaluate cell contents as a dot diagram.
        """
        magic.code = cell
        magic.cell_dot()
Esempio n. 17
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic
    kernel = IPythonKernel()
    magic = BrainMagic(kernel)

    @register_cell_magic
    def brain(line, cell):
        from IPython import get_ipython
        ipkernel = get_ipython()
        magic.code = cell
        magic.cell_brain()
        ipkernel.kernel.do_execute(magic.code, silent=True)
Esempio n. 18
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic, register_cell_magic
    kernel = IPythonKernel()
    magic = ConversationMagic(kernel)

    @register_line_magic
    def conversation(id):
        magic.line_conversation(id)

    @register_cell_magic
    def conversation(id, cell):
        magic.code = cell
        magic.cell_conversation(id)
Esempio n. 19
0
def register_ipython_magics():
    from metakernel import IPythonKernel
    from IPython.core.magic import register_line_magic, register_cell_magic
    kernel = IPythonKernel()
    magic = SchemeMagic(kernel)

    @register_line_magic
    def scheme(line):
        magic.line_scheme(line)
        return magic.retval

    @register_cell_magic
    def scheme(line, cell):
        magic.code = cell
        magic.cell_scheme()
        return magic.retval
Esempio n. 20
0
def register_ipython_magics():
    """For usage within ipykernel.

    This will instantiate the magics for IPython
    """
    from metakernel import IPythonKernel
    from IPython.core.magic import register_cell_magic, register_line_cell_magic
    kernel = IPythonKernel()
    scala_magic = ScalaMagic(kernel)
    init_spark_magic = InitSparkMagic(kernel)

    @register_line_cell_magic
    def scala(line, cell):
        if line:
            return scala_magic.line_scala(line)
        else:
            scala_magic.code = cell
            return scala_magic.cell_scala()

    @register_cell_magic
    def init_spark(line, cell):
        init_spark_magic.code = cell
        return init_spark_magic.cell_init_spark()