• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nbextensions.install_nbextension函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_install_destination_bad

 def test_install_destination_bad(self):
     with TemporaryDirectory() as d:
         zf = u'ƒ.zip'
         zsrc = pjoin(d, zf)
         with zipfile.ZipFile(zsrc, 'w') as z:
             z.writestr("a.js", b"b();")
     
         with self.assertRaises(ValueError):
             install_nbextension(zsrc, destination='foo')
开发者ID:AFJay,项目名称:notebook,代码行数:9,代码来源:test_nbextensions.py


示例17: test_install_symlink

 def test_install_symlink(self):
     with TemporaryDirectory() as d:
         f = u'ƒ.js'
         src = pjoin(d, f)
         touch(src)
         install_nbextension(src, symlink=True)
     dest = pjoin(self.system_nbext, f)
     assert os.path.islink(dest)
     link = os.readlink(dest)
     self.assertEqual(link, src)
开发者ID:AFJay,项目名称:notebook,代码行数:10,代码来源:test_nbextensions.py


示例18: test_check_nbextension

 def test_check_nbextension(self):
     with TemporaryDirectory() as d:
         f = u'ƒ.js'
         src = pjoin(d, f)
         touch(src)
         install_nbextension(src, user=True)
     
     assert check_nbextension(f, user=True)
     assert check_nbextension([f], user=True)
     assert not check_nbextension([f, pjoin('dne', f)], user=True)
开发者ID:AFJay,项目名称:notebook,代码行数:10,代码来源:test_nbextensions.py


示例19: install

 def install(self):
     """
     Install an extension (copy or symlinks)
     """
     try:
         install_nbextension(self.kwargs['static'], **self._install_params())
         self._echo("Installing {}".format(self.name), 'ok')
     except Exception as e:
         self._echo(e, None)
         self._echo("Installing {}".format(self.name), 'fail')
开发者ID:Anaconda-Platform,项目名称:nbsetuptools,代码行数:10,代码来源:nbsetuptools.py


示例20: run

 def run(self):
     _develop.run(self)
     install_nbextension(
         extension_dir,
         symlink=True,
         overwrite=True,
         user=False,
         sys_prefix=True,  # to install it inside virtualenv
         destination="robomission")
     cm = ConfigManager()
     cm.update('notebook', {"load_extensions": {"robomission/index": True } })
开发者ID:adaptive-learning,项目名称:robomission,代码行数:11,代码来源:setup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.ConfigManager类代码示例发布时间:2022-05-27
下一篇:
Python models.escape_rows函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap