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


Python BaseJSONConfigManager.set方法代码示例

本文整理汇总了Python中traitlets.config.manager.BaseJSONConfigManager.set方法的典型用法代码示例。如果您正苦于以下问题:Python BaseJSONConfigManager.set方法的具体用法?Python BaseJSONConfigManager.set怎么用?Python BaseJSONConfigManager.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在traitlets.config.manager.BaseJSONConfigManager的用法示例。


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

示例1: _install_kernelspec_manager

# 需要导入模块: from traitlets.config.manager import BaseJSONConfigManager [as 别名]
# 或者: from traitlets.config.manager.BaseJSONConfigManager import set [as 别名]
def _install_kernelspec_manager(prefix, disable=False):
    CKSM = "beakerx.kernel_spec.BeakerXKernelSpec"
    KSMC = "kernel_spec_class"

    action_prefix = "Dis" if disable else "En"
    log.info("{}abling BeakerX server config...".format(action_prefix))
    path = os.path.join(prefix, "etc", "jupyter")
    if not os.path.exists(path):
        log.debug("Making directory {}...".format(path))
        os.makedirs(path)
    cm = BaseJSONConfigManager(config_dir=path)
    cfg = cm.get("jupyter_notebook_config")
    log.debug("Existing config in {}...\n{}".format(path, _pretty(cfg)))
    nb_app = cfg.setdefault("KernelSpecManager", {})
    if disable and nb_app.get(KSMC, None) == CKSM:
        nb_app.pop(KSMC)
    elif not disable:
        nb_app.update({KSMC: CKSM})

    log.debug("Writing config in {}...".format(path))
    cm.set("jupyter_notebook_config", cfg)
    cfg = cm.get("jupyter_notebook_config")

    log.debug("Verifying config in {}...\n{}".format(path, _pretty(cfg)))
    if disable:
        assert KSMC not in cfg["KernelSpecManager"]
    else:
        assert cfg["KernelSpecManager"][KSMC] == CKSM

    log.info("{}abled BeakerX server config".format(action_prefix))
开发者ID:twosigma,项目名称:beaker-notebook,代码行数:32,代码来源:install.py

示例2: init_config_json

# 需要导入模块: from traitlets.config.manager import BaseJSONConfigManager [as 别名]
# 或者: from traitlets.config.manager.BaseJSONConfigManager import set [as 别名]
 def init_config_json(self):
     #save a config.json into the output dir
     print(print(self.config['Pipeline']))
     configmanager = BaseJSONConfigManager(config_dir=str(self._output))
     configmanager.set('config', self.config['Pipeline'])
     #save a config.json into the "pipeline subdir"
     configmanager = BaseJSONConfigManager(config_dir=str(self._output_subdir('pipeline')))
     configmanager.set('config', self.config['Pipeline'])
开发者ID:bassio,项目名称:ipype,代码行数:10,代码来源:pipeline.py

示例3: write_json_config

# 需要导入模块: from traitlets.config.manager import BaseJSONConfigManager [as 别名]
# 或者: from traitlets.config.manager.BaseJSONConfigManager import set [as 别名]
 def write_json_config(self):
     self.log.debug("Call: IPype.write_json_config().") #log
     #save a config.json into the output dir
     configmanager = BaseJSONConfigManager(config_dir=str(self._output))
     configmanager.set('config', self.config)
     self.log.debug("config.json file saved into the main output dir.") #log
     #save a config.json into the "pipeline subdir"
     configmanager = BaseJSONConfigManager(config_dir=str(self._output_subdir('pipeline')))
     configmanager.set('config', self.Pipeline.config)
     self.log.debug("config.json file saved into the pipeline subdir of the output dir.") #log
开发者ID:bassio,项目名称:ipype,代码行数:12,代码来源:app.py

示例4: install

# 需要导入模块: from traitlets.config.manager import BaseJSONConfigManager [as 别名]
# 或者: from traitlets.config.manager.BaseJSONConfigManager import set [as 别名]
def install(enable=False, disable=False, prefix=None, verbose=False):
    """Install the nb_conda_kernels config piece.

    Parameters
    ----------
    enable: bool
        Enable the BeakerX server config on every notebook launch
    disable: bool
        Disable BeakerX server config
    """
    if verbose:
        log.setLevel(logging.DEBUG)

    if enable == disable:
        log.error("Please provide (one of) --enable or --disable")
        raise ValueError(enable, disable)

    log.info("{}abling BeakerX server config...".format("En" if enable else "Dis"))

    path = jupyter_config_dir()

    if prefix is not None:
        path = join(prefix, "etc", "jupyter")
        if not exists(path):
            log.debug("Making directory {}...".format(path))
            os.makedirs(path)

    cm = BaseJSONConfigManager(config_dir=path)
    cfg = cm.get("jupyter_notebook_config")

    log.debug("Existing config in {}...\n{}".format(path, pretty(cfg)))

    nb_app = cfg.setdefault("KernelSpecManager", {})

    if enable:
        nb_app.update({KSMC: CKSM})
    elif disable and nb_app.get(KSMC, None) == CKSM:
        nb_app.pop(KSMC)

    log.debug("Writing config in {}...".format(path))

    cm.set("jupyter_notebook_config", cfg)

    cfg = cm.get("jupyter_notebook_config")

    log.debug("Verifying config in {}...\n{}".format(path, pretty(cfg)))

    if enable:
        assert cfg["KernelSpecManager"][KSMC] == CKSM
    else:
        assert KSMC not in cfg["KernelSpecManager"]

    log.info("{}abled BeakerX server config".format("En" if enable else "Dis"))
开发者ID:Jaykul,项目名称:beakerx,代码行数:55,代码来源:install.py


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