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

Python config.ConfigManager类代码示例

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

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



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

示例1: setup_info

def setup_info():
	server_cm = ConfigManager(config_dir=j_path.jupyter_config_dir())
	cfg = server_cm.get('jupyter_notebook_config')
	server_extensions = (cfg.setdefault('NotebookApp', {})
				.setdefault('server_extensions', [])
				)
	extension = 'hide_code.hide_code'
	if extension not in server_extensions:
		ext = 'Not loaded'
	else:
		ext = 'Loaded'

	files = []
	for (dirpath, dirnames, filenames) in os.walk(path.join(Utils.get_site_package_dir(), 'hide_code')):
		files.extend(filenames)
		break	

	custom_js = ''
	with open(path.join(Utils.get_site_package_dir(), 'notebook','static','custom','custom.js'), 'r') as f:
		for line in iter(f):
			if not line.startswith(' *') and not line.startswith('/'):
				custom_js = custom_js + line + ' '


	return ("Installation dir: {0}\nConfiguration dir: {1}\nExport handler extensions: {2}\nHide Code files: {3}\nCustom JS contents: {4}"
		.format(Utils.get_site_package_dir(), j_path.jupyter_config_dir(), ext, files, custom_js))
开发者ID:01-,项目名称:hide_code,代码行数:26,代码来源:hide_code.py


示例2: 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


示例3: install_server_extension

def install_server_extension(enable=True):
    """Register ipyparallel clusters tab as a notebook server extension
    
    Toggle with enable=True/False.
    """
    # server-side
    server = BaseJSONConfigManager(config_dir=jupyter_config_dir())
    server_cfg = server.get('jupyter_notebook_config')
    app_cfg = server_cfg.get('NotebookApp', {})
    server_extensions = app_cfg.get('server_extensions', [])
    server_ext = 'ipyparallel.nbextension'
    server_changed = False
    if enable and server_ext not in server_extensions:
        server_extensions.append(server_ext)
        server_changed = True
    elif (not enable) and server_ext in server_extensions:
        server_extensions.remove(server_ext)
        server_changed = True
    if server_changed:
        server.update('jupyter_notebook_config', {
            'NotebookApp': {
                'server_extensions': server_extensions,
            }
        })
    
    # frontend config (*way* easier because it's a dict)
    frontend = FrontendConfigManager()
    frontend.update('tree', {
        'load_extensions': {
            'ipyparallel/main': enable or None,
        }
    })
开发者ID:AminJamalzadeh,项目名称:ipyparallel,代码行数:32,代码来源:install.py


示例4: start

 def start(self):
     self.log.info("Activating jupyter_dashboards_bundlers JS notebook extensions")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'dashboards_local_deploy': {
                 'label': 'Local Dashboard',
                 'module_name': 'dashboards_bundlers.local_deploy',
                 'group': 'deploy'
             },
             'dashboards_php_download': {
                 'label': 'PHP Dashboard bundle (.zip)',
                 'module_name': 'dashboards_bundlers.php_download',
                 'group': 'download'
             },
             'dashboards_server_upload': {
                 'label': 'Dashboard on Jupyter Dashboards Server',
                 'module_name': 'dashboards_bundlers.server_upload',
                 'group': 'deploy'
             },
             'dashboards_server_download': {
                 'label': 'Jupyter Dashboards Server bundle (.zip)',
                 'module_name': 'dashboards_bundlers.server_download',
                 'group': 'download'
             }
         }
     })
     self.log.info("Done.")
开发者ID:ScottJWalter,项目名称:dashboards_bundlers,代码行数:28,代码来源:extensionapp.py


示例5: _install_extension_nb41

def _install_extension_nb41(enable=True):
    """deprecated, pre-4.2 implementation of installing notebook extension"""
    # server-side
    server = BaseJSONConfigManager(config_dir=jupyter_config_dir())
    server_cfg = server.get('jupyter_notebook_config')
    app_cfg = server_cfg.get('NotebookApp', {})
    server_extensions = app_cfg.get('server_extensions', [])
    server_ext = 'ipyparallel.nbextension'
    server_changed = False
    if enable and server_ext not in server_extensions:
        server_extensions.append(server_ext)
        server_changed = True
    elif (not enable) and server_ext in server_extensions:
        server_extensions.remove(server_ext)
        server_changed = True
    if server_changed:
        server.update('jupyter_notebook_config', {
            'NotebookApp': {
                'server_extensions': server_extensions,
            }
        })
    
    # frontend config (*way* easier because it's a dict)
    frontend = FrontendConfigManager()
    frontend.update('tree', {
        'load_extensions': {
            'ipyparallel/main': enable or None,
        }
    })
开发者ID:Ruk0610,项目名称:ipyparallel,代码行数:29,代码来源:install.py


示例6: __init__

    def __init__(self, *args, **kwargs):
        super(ExporterCollapsibleHeadings, self).__init__(*args, **kwargs)

        self.inliner_resources['css'].append("""
/* no local copies of fontawesome fonts in basic templates, so use cdn */
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css)
""")  # noqa: E501

        ch_dir = os.path.join(
            os.path.dirname(contrib_init), 'nbextensions',
            'collapsible_headings')

        with open(os.path.join(ch_dir, 'main.css'), 'r') as f:
            self.inliner_resources['css'].append(f.read())

        with open(os.path.join(ch_dir, 'main.js'), 'r') as f:
            self.inliner_resources['js'].append(f.read())

        cm = ConfigManager()
        collapsible_headings_options = cm.get('notebook').get(
            'collapsible_headings', {})
        self.inliner_resources['js'].append("""
$(document).ready(function () {
    require(['nbextensions/collapsible_headings/main'], function (ch) {
        ch.set_collapsible_headings_options(%s);
        ch.refresh_all_headings();
    });
});
""" % json.dumps(collapsible_headings_options))
开发者ID:codegenerator-tools,项目名称:jupyter_contrib_nbextensions,代码行数:29,代码来源:collapsible_headings.py


示例7: 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


示例8: 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


示例9: disable_nbextension

 def disable_nbextension(self, name):
     # Local import to avoid circular import issue on Py 2
     from notebook.services.config import ConfigManager
     cm = ConfigManager(parent=self, config=self.config)
     if name not in cm.get(self.section).get('load_extensions', {}):
         sys.exit('{} is not enabled in section {}'.format(name, self.section))
     # We're using a dict as a set - updating with None removes the key
     cm.update(self.section, {"load_extensions": {name: None}})
开发者ID:nwhitehead,项目名称:notebook,代码行数:8,代码来源:nbextensions.py


示例10: disable_bundler

 def disable_bundler(self):
     '''Disables the notebook bundler extension.'''
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'notebook_associations_download': None
         }
     })
开发者ID:jupyter-incubator,项目名称:contentmanagement,代码行数:8,代码来源:extensionapp.py


示例11: start

 def start(self):
     self.log.info("Deactivating jupyter_kernel_gateway_bundlers notebook extension")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', {
         'jupyter_cms_bundlers': {
             'microservice_dockerfile_download' : None
         }
     })
     self.log.info("Done.")
开发者ID:jupyter-incubator,项目名称:kernel_gateway_bundlers,代码行数:9,代码来源:extensionapp.py


示例12: get_bundler

 def get_bundler(self, bundler_id):
     '''
     :param bundler_id: Unique ID within the notebook/jupyter_cms_bundlers
     config section.
     :returns: Dict of bundler metadata with keys label, group, module_name
     :raises KeyError: If the bundler is not registered
     '''
     cm = ConfigManager()
     return cm.get('notebook').get('jupyter_cms_bundlers', {})[bundler_id]
开发者ID:bucweat,项目名称:contentmanagement,代码行数:9,代码来源:bundler.py


示例13: config_configManager

def config_configManager():
    print("Update ConfigManager")
    from notebook.services.config import ConfigManager
    cm = ConfigManager()
    cm.update('livereveal', {
              'theme': 'serif',
              'start_slideshow_at': 'selected',
              'width': 1680,
              'height': 768,
    })
开发者ID:r0k3,项目名称:thalesians,代码行数:10,代码来源:config.py


示例14: __init__

 def __init__(self, name, **kwargs):
     self.name = name
     self.prefix = kwargs.get('prefix', None)
     self.kwargs = kwargs
     if self.prefix is None:
         self.path = jupyter_config_dir()
     else:
         self.path = join(self.prefix, "etc", "jupyter")
     self.cm = ConfigManager(config_dir=join(self.path, 'nbconfig'))
     self.cm_server = ConfigManager(config_dir=self.path)
开发者ID:Anaconda-Platform,项目名称:nbsetuptools,代码行数:10,代码来源:nbsetuptools.py


示例15: install

def install(enable=False, disable=False, prefix=None):
    """Install the nb_config_manager config piece.

    Parameters
    ----------
    enable: bool
        Enable the nb_config_manager on every notebook launch
    disable: bool
        Disable nb_config_manager on every notebook launch
    """
    from notebook.services.config import ConfigManager

    if enable:
        if prefix is not None:
            path = join(prefix, "etc", "jupyter")
            if not exists(path):
                print("Making directory", path)
                os.makedirs(path)
        else:
            path = jupyter_config_dir()

        cm = ConfigManager(config_dir=path)
        print("Enabling nb_config_manager in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)

        notebook_app = cfg.setdefault("NotebookApp", {})
        if "config_manager_class" not in notebook_app:
            cfg["NotebookApp"]["config_manager_class"] = "nb_config_manager.EnvironmentConfigManager"

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

    if disable:
        if prefix is not None:
            path = join(prefix, "etc", "jupyter")
        else:
            path = jupyter_config_dir()

        cm = ConfigManager(config_dir=path)
        print("Disabling nb_config_manager in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)

        config_manager = cfg["NotebookApp"]["config_manager_class"]

        if "nb_config_manager.EnvironmentConfigManager" == config_manager:
            cfg["NotebookApp"].pop("config_manager_class")

        cm.set("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))
开发者ID:fdeheeger,项目名称:nb_config_manager,代码行数:55,代码来源:install.py


示例16: _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


示例17: 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


示例18: start

 def start(self):
     self.log.info("Deactivating jupyter_dashboards_bundlers JS notebook extensions")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'dashboards_local_deploy' : None,
             'dashboards_php_download' : None,
             'dashboards_server_upload' : None
         }
     })
     self.log.info("Done.")
开发者ID:deedubbu,项目名称:dashboards_bundlers,代码行数:11,代码来源:extensionapp.py


示例19: run_nbextension_install

 def run_nbextension_install(develop):
     import sys
     sysprefix = hasattr(sys, 'real_prefix')
     if sysprefix:
         install_nbextension(extension_dir, symlink=develop, sys_prefix=sysprefix)
     else:
         install_nbextension(extension_dir, symlink=develop, user=user)
     if enable is not None:
         print("Enabling the extension ...")
         cm = ConfigManager()
         cm.update('notebook', {"load_extensions": {enable: True}})
开发者ID:exe0cdc,项目名称:jupyter-pip,代码行数:11,代码来源:__init__.py


示例20: enable_bundler

 def enable_bundler(self):
     '''Enables the notebook bundler extension.'''
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'notebook_associations_download': {
                 'label': 'IPython Notebook bundle (.zip)',
                 'module_name': 'jupyter_cms.nb_bundler',
                 'group': 'download'
             }
         }
     })
开发者ID:jupyter-incubator,项目名称:contentmanagement,代码行数:12,代码来源:extensionapp.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python launchnotebook.assert_http_error函数代码示例发布时间:2022-05-27
下一篇:
Python nbextensions.install_nbextension函数代码示例发布时间: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