当前位置: 首页>>代码示例>>Python>>正文


Python nbextensions.install_nbextension函数代码示例

本文整理汇总了Python中notebook.nbextensions.install_nbextension函数的典型用法代码示例。如果您正苦于以下问题:Python install_nbextension函数的具体用法?Python install_nbextension怎么用?Python install_nbextension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了install_nbextension函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load the nbserver"""
    windows = sys.platform.startswith('win')
    webapp = nbapp.web_app
    webapp.settings['example_manager'] = Examples(parent=nbapp)
    base_url = webapp.settings['base_url']

    install_nbextension(static, destination='nbexamples', symlink=not windows,
                        user=True)
    cfgm = nbapp.config_manager
    cfgm.update('tree', {
        'load_extensions': {
            'nbexamples/main': True,
        }
    })
    cfgm.update('notebook', {
        'load_extensions': {
            'nbexamples/submit-example-button': True,
        }
    })

    ExampleActionHandler.base_url = base_url  # used to redirect after fetch
    webapp.add_handlers(".*$", [
        (ujoin(base_url, pat), handler)
        for pat, handler in default_handlers
    ])
开发者ID:jai11,项目名称:nbexamples,代码行数:26,代码来源:handlers.py

示例2: test_create_nbextensions_user

 def test_create_nbextensions_user(self):
     with TemporaryDirectory() as td:
         install_nbextension(self.src, user=True)
         self.assert_installed(
             pjoin(basename(self.src), u'ƒile'),
             user=True
         )
开发者ID:dhirschfeld,项目名称:notebook,代码行数:7,代码来源:test_nbextensions.py

示例3: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load the nbserver"""
    windows = sys.platform.startswith('win')
    webapp = nbapp.web_app
    webapp.settings['shared_manager'] = SharedManager(parent=nbapp)
    base_url = webapp.settings['base_url']

    install_nbextension(static, destination='nbshared', symlink=not windows, user=True)

    # cfgm = nbapp.config_manager
    # cfgm.update('tree', {
    #     'load_extensions': {
    #         'nbexamples/main': True,
    #     }
    # })
    # cfgm.update('notebook', {
    #     'load_extensions': {
    #         'nbexamples/submit-example-button': True,
    #     }
    # })

    webapp.add_handlers(".*$", [
        (ujoin(base_url, pat), handler)
        for pat, handler in default_handlers
    ])
开发者ID:Valdimus,项目名称:nbshared,代码行数:25,代码来源:handlers.py

示例4: setup_extensions

 def setup_extensions(self, CUR_EXT, EXT_DIR, DIR):
     # Install the extensions to the required directories
     ensure_dir_exists(DIR)
     if os.path.exists(CUR_EXT):
         question = "ACTION: The Stepsize extension directory already " \
                    "exists, do you want to overwrite %s with the " \
                    "current installation?" % (CUR_EXT)
         prompt = self.query(question)
         if prompt == "yes":
             try:
                 install_nbextension(EXT_DIR, overwrite=True,
                                     nbextensions_dir=DIR)
                 print("OUTCOME: Added the extension to your "
                       "%s directory" % (DIR))
             except:
                 print("WARNING: Unable to install the extension to your "
                       "(nb)extensions folder")
                 print("ERROR: %s" % (sys.exc_info()[0]))
                 raise
         else:
             return
     else:
         try:
             install_nbextension(EXT_DIR, overwrite=True,
                                 nbextensions_dir=DIR)
             print("OUTCOME: Added the extension to your %s directory"
                   % (DIR))
         except:
             print("WARNING: Unable to install the extension to your "
                   "(nb)extensions folder")
             print("ERROR: %s" % (sys.exc_info()[0]))
             raise
开发者ID:Stepsize,项目名称:jupyter_search,代码行数:32,代码来源:setup.py

示例5: install

def install(user=False, symlink=False, quiet=False, enable=False):
    """Install the widget nbextension and optionally enable it.
    
    Parameters
    ----------
    user: bool
        Install for current user instead of system-wide.
    symlink: bool
        Symlink instead of copy (for development).
    enable: bool
        Enable the extension after installing it.
    quiet: bool
        Suppress print statements about progress.
    """
    if not quiet:
        print("Installing nbextension ...")
    staticdir = pjoin(dirname(abspath(__file__)), "static")
    install_nbextension(staticdir, destination="widgets", user=user, symlink=symlink)

    if enable:
        if not quiet:
            print("Enabling the extension ...")
        cm = ConfigManager()
        cm.update("notebook", {"load_extensions": {"widgets/extension": True}})
    if not quiet:
        print("Done.")
开发者ID:parente,项目名称:ipywidgets,代码行数:26,代码来源:install.py

示例6: _install_notebook_extension

def _install_notebook_extension():
    print('Installing notebook extension')
    install_nbextension(EXT_DIR, overwrite=True, user=True)
    cm = ConfigManager()
    print('Enabling extension for notebook')
    cm.update('notebook', {"load_extensions": {'urth_cms_js/notebook/main': True}})
    print('Enabling extension for dashboard')
    cm.update('tree', {"load_extensions": {'urth_cms_js/dashboard/main': True}})
    print('Enabling extension for text editor')
    cm.update('edit', {"load_extensions": {'urth_cms_js/editor/main': True}})
    print('Enabling notebook and associated files bundler')
    cm.update('notebook', { 
      'jupyter_cms_bundlers': {
        'notebook_associations_download': {
          'label': 'IPython Notebook bundle (.zip)',
          'module_name': 'urth.cms.nb_bundler',
          'group': 'download'
        }
      }
    })

    print('Installing notebook server extension')
    fn = os.path.join(jupyter_config_dir(), 'jupyter_notebook_config.py')
    with open(fn, 'r+') as fh:
        lines = fh.read()
        if SERVER_EXT_CONFIG not in lines:
            fh.seek(0, 2)
            fh.write('\n')
            fh.write(SERVER_EXT_CONFIG)
开发者ID:radudragusin,项目名称:contentmanagement,代码行数:29,代码来源:setup.py

示例7: install

def install(user=False, symlink=False, overwrite=False, enable=False,
            **kwargs):
    """Install the nbpresent nbextension.

    Parameters
    ----------
    user: bool
        Install for current user instead of system-wide.
    symlink: bool
        Symlink instead of copy (for development).
    overwrite: bool
        Overwrite previously-installed files for this extension
    enable: bool
        Enable the extension on every notebook launch
    **kwargs: keyword arguments
        Other keyword arguments passed to the install_nbextension command
    """
    print("Installing nbpresent nbextension...")
    directory = join(dirname(abspath(__file__)), 'static', 'nbpresent')
    install_nbextension(directory, destination='nbpresent',
                        symlink=symlink, user=user, overwrite=overwrite,
                        **kwargs)

    if enable:
        print("Enabling nbpresent at every notebook launch...")
        cm = ConfigManager()
        cm.update('notebook',
                  {"load_extensions": {"nbpresent/nbpresent.min": True}})
开发者ID:fiolbs,项目名称:nbpresent,代码行数:28,代码来源:install.py

示例8: enable_notebook

def enable_notebook():
    """Enable IPython notebook widgets to be displayed.

    This function should be called before using TrajectoryWidget.
    """
    display(_REQUIRE_CONFIG)
    staticdir =  resource_filename('mdview', os.path.join('html', 'static'))
    install_nbextension(staticdir, destination='mdview', user=True)
开发者ID:hainm,项目名称:mdview,代码行数:8,代码来源:install.py

示例9: test_single_dir_trailing_slash

 def test_single_dir_trailing_slash(self):
     d = u'∂ir/'
     install_nbextension(pjoin(self.src, d))
     self.assert_installed(self.files[-1])
     if os.name == 'nt':
         d = u'∂ir\\'
         install_nbextension(pjoin(self.src, d))
         self.assert_installed(self.files[-1])
开发者ID:dhirschfeld,项目名称:notebook,代码行数:8,代码来源:test_nbextensions.py

示例10: install

def install(config_dir, use_symlink=False, enable=True):
    # Install the livereveal code.
    install_nbextension(livereveal_dir, symlink=use_symlink,
                        overwrite=use_symlink, user=True)

    if enable:
        cm = ConfigManager(config_dir=config_dir)
        cm.update('notebook', {"load_extensions": {"livereveal/main": True}})
开发者ID:bwilk7,项目名称:RISE,代码行数:8,代码来源:setup.py

示例11: test_create_nbextensions_user

 def test_create_nbextensions_user(self):
     with TemporaryDirectory() as td:
         self.data_dir = pjoin(td, u'jupyter_data')
         install_nbextension(self.src, user=True)
         self.assert_installed(
             pjoin(basename(self.src), u'ƒile'),
             user=True
         )
开发者ID:AFJay,项目名称:notebook,代码行数:8,代码来源:test_nbextensions.py

示例12: test_quiet

 def test_quiet(self):
     stdout = StringIO()
     stderr = StringIO()
     with patch.object(sys, 'stdout', stdout), \
          patch.object(sys, 'stderr', stderr):
         install_nbextension(self.src, verbose=0)
     self.assertEqual(stdout.getvalue(), '')
     self.assertEqual(stderr.getvalue(), '')
开发者ID:AFJay,项目名称:notebook,代码行数:8,代码来源:test_nbextensions.py

示例13: test_install_zip

 def test_install_zip(self):
     path = pjoin(self.src, "myjsext.zip")
     with zipfile.ZipFile(path, 'w') as f:
         f.writestr("a.js", b"b();")
         f.writestr("foo/a.js", b"foo();")
     install_nbextension(path)
     self.assert_installed("a.js")
     self.assert_installed(pjoin("foo", "a.js"))
开发者ID:AFJay,项目名称:notebook,代码行数:8,代码来源:test_nbextensions.py

示例14: install

def install(enable=False, **kwargs):
    """Install the nbpresent nbextension assets and optionally enables the
       nbextension and server extension for every run.

    Parameters
    ----------
    enable: bool
        Enable the extension on every notebook launch
    **kwargs: keyword arguments
        Other keyword arguments passed to the install_nbextension command
    """
    from notebook.nbextensions import install_nbextension
    from notebook.services.config import ConfigManager

    directory = join(dirname(abspath(__file__)), "static", "nbpresent")

    kwargs = {k: v for k, v in kwargs.items() if not (v is None)}

    kwargs["destination"] = "nbpresent"
    install_nbextension(directory, **kwargs)

    if enable:
        path = jupyter_config_dir()
        if "prefix" in kwargs:
            path = join(kwargs["prefix"], "etc", "jupyter")
            if not exists(path):
                print("Making directory", path)
                os.makedirs(path)

        cm = ConfigManager(config_dir=path)
        print("Enabling nbpresent server component in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)
        server_extensions = cfg.setdefault("NotebookApp", {}).setdefault("server_extensions", [])
        if "nbpresent" not in server_extensions:
            cfg["NotebookApp"]["server_extensions"] += ["nbpresent"]

        cm.update("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))

        _jupyter_config_dir = jupyter_config_dir()
        # try:
        #     subprocess.call(["conda", "info", "--root"])
        #     print("conda detected")
        #     _jupyter_config_dir = ENV_CONFIG_PATH[0]
        # except OSError:
        #     print("conda not detected")

        cm = ConfigManager(config_dir=join(_jupyter_config_dir, "nbconfig"))
        print("Enabling nbpresent nbextension at notebook launch in", cm.config_dir)

        if not exists(cm.config_dir):
            print("Making directory", cm.config_dir)
            os.makedirs(cm.config_dir)

        cm.update("notebook", {"load_extensions": {"nbpresent/nbpresent.min": True}})
开发者ID:bollwyvl,项目名称:nbpresent,代码行数:58,代码来源:install.py

示例15: test_create_nbextensions_system

 def test_create_nbextensions_system(self):
     with TemporaryDirectory() as td:
         self.system_nbext = pjoin(td, u'nbextensions')
         with patch.object(nbextensions, 'SYSTEM_JUPYTER_PATH', [td]):
             install_nbextension(self.src, user=False)
             self.assert_installed(
                 pjoin(basename(self.src), u'ƒile'),
                 user=False
             )
开发者ID:AFJay,项目名称:notebook,代码行数:9,代码来源:test_nbextensions.py


注:本文中的notebook.nbextensions.install_nbextension函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。