Пример #1
0
def save_ipyvolumejs(
    target="", devmode=False, version=ipyvolume._version.__version_js__, version3js=__version_threejs__
):
    """Output the ipyvolume javascript to a local file.

    :type target: str
    :param bool devmode: if True get index.js from js/dist directory
    :param str version: version number of ipyvolume
    :param str version3js: version number of threejs

    """
    url = "https://unpkg.com/ipyvolume@{version}/dist/index.js".format(version=version)
    pyv_filename = 'ipyvolume_v{version}.js'.format(version=version)
    pyv_filepath = os.path.join(target, pyv_filename)

    devfile = os.path.join(os.path.abspath(ipyvolume.__path__[0]), "..", "js", "dist", "index.js")
    if devmode:
        if not os.path.exists(devfile):
            raise IOError('devmode=True but cannot find : {}'.format(devfile))
        if target and not os.path.exists(target):
            os.makedirs(target)
        shutil.copy(devfile, pyv_filepath)
    else:
        download_to_file(url, pyv_filepath)

    # TODO: currently not in use, think about this if we want to have this external for embedding,
    # see also https://github.com/jovyan/pythreejs/issues/109
    # three_filename = 'three_v{version}.js'.format(version=__version_threejs__)
    # three_filepath = os.path.join(target, three_filename)
    # threejs = os.path.join(os.path.abspath(ipyvolume.__path__[0]), "static", "three.js")
    # shutil.copy(threejs, three_filepath)

    return pyv_filename  # , three_filename
Пример #2
0
def save_requirejs(target="", version="2.3.4"):
    """Download and save the require javascript to a local file.

    :type target: str
    :type version: str
    """
    url = "https://cdnjs.cloudflare.com/ajax/libs/require.js/{version}/require.min.js".format(version=version)
    filename = "require.min.v{0}.js".format(version)
    filepath = os.path.join(target, filename)
    download_to_file(url, filepath)
    return filename
Пример #3
0
def save_embed_js(target="", version=wembed.__html_manager_version__):
    """Download and save the ipywidgets embedding javascript to a local file.

    :type target: str
    :type version: str

    """
    url = u'https://unpkg.com/@jupyter-widgets/html-manager@{0:s}/dist/embed-amd.js'.format(version)
    if version.startswith('^'):
        version = version[1:]
    filename = "embed-amd_v{0:s}.js".format(version)
    filepath = os.path.join(target, filename)

    download_to_file(url, filepath)
    return filename