##// END OF EJS Templates
Major refactoring of the Notebook, Kernel and CodeCell JavaScript....
Major refactoring of the Notebook, Kernel and CodeCell JavaScript. * Kernel doesn't depend on Notebook or CodeCell. * CodeCell doesn't depend on Notebook, only Kernel. * All of the kernel management logic has been moved out of the Notebook into the Kernel. * Public methods of the Kernel (execute, complete, etc) take a callbacks object that registers the callbacks for that msg. (rebased, cherrypicked, by Bussonnier Matthias <bussonniermatthias@gmail.com>) (and tabs removed) Conflicts: IPython/frontend/html/notebook/static/js/codecell.js IPython/frontend/html/notebook/static/js/completer.js IPython/frontend/html/notebook/static/js/tooltip.js

File last commit:

r6973:1f1d8fa1
r7168:cf831228
Show More
extension.py
69 lines | 2.4 KiB | text/x-python | PythonLexer
"""Implementation of magic functions for the extension machinery.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2012 The IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Stdlib
import os
# Our own packages
from IPython.core.magic import Magics, magics_class, line_magic
#-----------------------------------------------------------------------------
# Magic implementation classes
#-----------------------------------------------------------------------------
@magics_class
class ExtensionMagics(Magics):
"""Magics to manage the IPython extensions system."""
@line_magic
def install_ext(self, parameter_s=''):
"""Download and install an extension from a URL, e.g.::
%install_ext https://bitbucket.org/birkenfeld/ipython-physics/raw/d1310a2ab15d/physics.py
The URL should point to an importable Python module - either a .py file
or a .zip file.
Parameters:
-n filename : Specify a name for the file, rather than taking it from
the URL.
"""
opts, args = self.parse_options(parameter_s, 'n:')
try:
filename = self.shell.extension_manager.install_extension(args,
opts.get('n'))
except ValueError as e:
print e
return
filename = os.path.basename(filename)
print "Installed %s. To use it, type:" % filename
print " %%load_ext %s" % os.path.splitext(filename)[0]
@line_magic
def load_ext(self, module_str):
"""Load an IPython extension by its module name."""
return self.shell.extension_manager.load_extension(module_str)
@line_magic
def unload_ext(self, module_str):
"""Unload an IPython extension by its module name."""
self.shell.extension_manager.unload_extension(module_str)
@line_magic
def reload_ext(self, module_str):
"""Reload an IPython extension by its module name."""
self.shell.extension_manager.reload_extension(module_str)