Did I find the right examples for you? yes no

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Install a Javascript extension for the notebook

Stages files and/or directories into IPYTHONDIR/nbextensions.
By default, this compares modification time, and only stages files that need updating.
If `overwrite` is specified, matching files are purged before proceeding.

Parameters
----------

files : list(paths or URLs)(more...)

        def install_nbextension(files, overwrite=False, symlink=False, ipython_dir=None, verbose=1):
    """Install a Javascript extension for the notebook
    
    Stages files and/or directories into IPYTHONDIR/nbextensions.
    By default, this compares modification time, and only stages files that need updating.
    If `overwrite` is specified, matching files are purged before proceeding.
    
    Parameters
    ----------
    
    files : list(paths or URLs)
        One or more paths or URLs to existing files directories to install.
        These will be installed with their base name, so '/path/to/foo'
        will install to 'nbextensions/foo'.
        Archives (zip or tarballs) will be extracted into the nbextensions directory.
    overwrite : bool [default: False]
        If True, always install the files, regardless of what may already be installed.
    symlink : bool [default: False]
        If True, create a symlink in nbextensions, rather than copying files.
        Not allowed with URLs or archives.
    ipython_dir : str [optional]
        The path to an IPython directory, if the default value is not desired.
        get_ipython_dir() is used by default.
    verbose : int [default: 1]
        Set verbosity level. The default is 1, where file actions are printed.
        set verbose=2 for more output, or verbose=0 for silence.
    """
    
    ipython_dir = ipython_dir or get_ipython_dir()
    nbext = pjoin(ipython_dir, u'nbextensions')
    # make sure nbextensions dir exists
    if not os.path.exists(nbext):
        os.makedirs(nbext)
    
    if isinstance(files, string_types):
        # one file given, turn it into a list
        files = [files]
    
    for path in map(cast_unicode_py2, files):
        
        if path.startswith(('https://', 'http://')):
            if symlink:
                raise ValueError("Cannot symlink from URLs")
            # Given a URL, download it
            with TemporaryDirectory() as td:
                filename = urlparse(path).path.split('/')[-1]
                local_path = os.path.join(td, filename)
                if verbose >= 1:
                    print("downloading %s to %s" % (path, local_path))
                urlretrieve(path, local_path)
                # now install from the local copy
                install_nbextension(local_path, overwrite, symlink, ipython_dir, verbose)
            continue
        
        # handle archives
        archive = None
        if path.endswith('.zip'):
            archive = zipfile.ZipFile(path)
        elif _safe_is_tarfile(path):
            archive = tarfile.open(path)
        
        if archive:
            if symlink:
                raise ValueError("Cannot symlink from archives")
            if verbose >= 1:
                print("extracting %s to %s" % (path, nbext))
            archive.extractall(nbext)
            archive.close()
            continue
        
        dest = pjoin(nbext, basename(path))
        if overwrite and os.path.exists(dest):
            if verbose >= 1:
                print("removing %s" % dest)
            if os.path.isdir(dest):
                shutil.rmtree(dest)
            else:
                os.remove(dest)
        
        if symlink:
            path = os.path.abspath(path)
            if not os.path.exists(dest):
                if verbose >= 1:
                    print("symlink %s -> %s" % (dest, path))
                os.symlink(path, dest)
            continue

        if os.path.isdir(path):
            strip_prefix_len = len(path) - len(basename(path))
            for parent, dirs, files in os.walk(path):
                dest_dir = pjoin(nbext, parent[strip_prefix_len:])
                if not os.path.exists(dest_dir):
                    if verbose >= 2:
                        print("making directory %s" % dest_dir)
                    os.makedirs(dest_dir)
                for file in files:
                    src = pjoin(parent, file)
                    # print("%r, %r" % (dest_dir, file))
                    dest = pjoin(dest_dir, file)
                    _maybe_copy(src, dest, verbose)
        else:
            src = path
            _maybe_copy(src, dest, verbose)
        


src/i/p/ipython-2.0.0/IPython/html/__init__.py   ipython(Download)
del os
 
from .nbextensions import install_nbextension

src/i/p/ipython-HEAD/IPython/html/__init__.py   ipython(Download)
del os
 
from .nbextensions import install_nbextension