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


Python loader.Config方法代码示例

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


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

示例1: main

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def main():
    args = parse_args()
    archives = args.archives
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    excludes = parse_exclude(args.exclude) if args.exclude else ["*.log"]

    conf = analyze(archives, excludes)  # noqa F841 / unused var

    # import all the built-in predicates
    from insights.parsr.query import (lt, le, eq, gt, ge, isin, contains,  # noqa: F403
            startswith, endswith, ieq, icontains, istartswith, iendswith,  # noqa: F403
            matches, make_child_query)  # noqa: F403
    q = make_child_query  # noqa: F405

    import IPython
    from traitlets.config.loader import Config

    IPython.core.completer.Completer.use_jedi = False
    c = Config()
    c.TerminalInteractiveShell.banner1 = banner
    IPython.start_ipython([], user_ns=locals(), config=c) 
开发者ID:RedHatInsights,项目名称:insights-core,代码行数:25,代码来源:ocpshell.py

示例2: test_extractor_tel_param

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_extractor_tel_param(toymodel):
    waveforms, subarray, _, _, _, _ = toymodel
    _, n_samples = waveforms.shape

    config = Config(
        {
            "ImageExtractor": {
                "window_width": [("type", "*", n_samples), ("id", "2", n_samples // 2)],
                "peak_index": 0,
            }
        }
    )

    waveforms, subarray, _, _, _, _ = toymodel
    n_pixels, n_samples = waveforms.shape
    extractor = ImageExtractor.from_name(
        "FixedWindowSum", subarray=subarray, config=config
    )

    assert extractor.peak_index.tel[None] == 0
    assert extractor.peak_index.tel[1] == 0
    assert extractor.peak_index.tel[2] == 0
    assert extractor.window_width.tel[None] == n_samples
    assert extractor.window_width.tel[1] == n_samples
    assert extractor.window_width.tel[2] == n_samples // 2 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:27,代码来源:test_extractor.py

示例3: client

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def client(**kwargs):
    """Start a REPL shell, with an already configured Clearly Client `clearlycli`.

    \b
    HOST: The host where Clearly Server is running, default localhost
    PORT: The port where Clearly Server is running, default 12223
    """
    from clearly.client import ClearlyClient, ModeTask, ModeWorker
    share = dict(
        clearlycli=ClearlyClient(**{k: v for k, v in kwargs.items() if v}),
        ModeTask=ModeTask, ModeWorker=ModeWorker,
    )

    # the first option was bpython, but unfortunately it is broken...
    # https://github.com/bpython/bpython/issues/758
    # from bpython import embed
    # embed(dict(clearlycli=clearlycli))

    import IPython
    from traitlets.config.loader import Config
    c = Config()
    c.TerminalInteractiveShell.banner1 = logo.render('client') + '\n'
    c.TerminalInteractiveShell.banner2 = 'Clearly client is ready to use: clearlycli'
    IPython.start_ipython(argv=[], user_ns=share, config=c) 
开发者ID:rsalmei,项目名称:clearly,代码行数:26,代码来源:command_line.py

示例4: _load_config

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def _load_config(self, cfg: Config, **kwargs: Any) -> None:
        if 'code_stub' in cfg.ClearSolutions:
            if not isinstance(cfg.ClearSolutions.code_stub, dict):
                self.log.warning(
                    "The ClearSolutions.code_stub option must now be given as a "
                    "dictionary with keys for the language of the notebook. I will "
                    "automatically convert ClearSolutions.code_stub to a dictionary "
                    "with a key for 'python', but note that this functionality may "
                    "be removed in future releases.")
                cfg.ClearSolutions.code_stub = dict(python=cfg.ClearSolutions.code_stub)

        if 'comment_mark' in cfg.ClearSolutions:
            self.log.warning(
                "The ClearSolutions.comment_mark config option is deprecated. "
                "Please include the comment mark in ClearSolutions.begin_solution_delimeter "
                "and ClearSolutions.end_solution_delimeter instead.")
            del cfg.ClearSolutions.comment_mark

        super(ClearSolutions, self)._load_config(cfg, **kwargs) 
开发者ID:jupyter,项目名称:nbgrader,代码行数:21,代码来源:clearsolutions.py

示例5: Shell

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def Shell(user_session):
    # This should bring back the old autocall behaviour. e.g.:
    # In [1]: pslist
    cfg = Config()
    cfg.InteractiveShellEmbed.autocall = 2
    cfg.TerminalInteractiveShell.prompts_class = RekallPrompt
    cfg.InteractiveShell.separate_in = ''
    cfg.InteractiveShell.separate_out = ''
    cfg.InteractiveShell.separate_out2 = ''

    shell = RekallShell(config=cfg, user_ns=user_session.locals)

    shell.Completer.merge_completions = False
    shell.exit_msg = constants.GetQuote()
    shell.set_custom_completer(RekallCompleter, 0)

    # Do we need to pre-run something?
    if user_session.run != None:
        execfile(user_session.run, user_session.locals)

    user_session.shell = shell

    # Set known delimeters for the completer. This varies by OS so we need to
    # set it to ensure consistency.
    readline.set_completer_delims(' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?')

    for magic in REGISTERED_MAGICS:
        shell.register_magics(magic)

    shell(module=user_session.locals, )

    return True 
开发者ID:google,项目名称:rekall,代码行数:34,代码来源:ipython_support.py

示例6: start_session

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def start_session(paths, change_directory=False, __coverage=None):
    __cwd = os.path.abspath(os.curdir)

    def callback(brokers):
        models = Holder()
        for i, (path, broker) in enumerate(brokers):
            avail = _get_available_models(broker)
            if paths:
                if len(paths) > 1:
                    models[paths[i]] = Models(broker, avail, __cwd, path, __coverage)
                else:
                    models = Models(broker, avail, __cwd, path, __coverage)
            else:
                models = Models(broker, avail, __cwd, path, __coverage)

        if change_directory and len(brokers) == 1:
            __working_path, _ = brokers[0]
            os.chdir(__working_path)
        # disable jedi since it won't autocomplete for objects with__getattr__
        # defined.
        IPython.core.completer.Completer.use_jedi = False
        __cfg = Config()
        __cfg.TerminalInteractiveShell.banner1 = Models.__doc__
        __ns = {}
        __ns.update(globals())
        __ns.update({"models": models})
        IPython.start_ipython([], user_ns=__ns, config=__cfg)

    with_brokers(paths, callback)
    if change_directory:
        os.chdir(__cwd) 
开发者ID:RedHatInsights,项目名称:insights-core,代码行数:33,代码来源:shell.py

示例7: test_waveform_extractor_factory_args

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_waveform_extractor_factory_args(subarray):
    """
    Config is supposed to be created by a `Tool`
    """
    config = Config({"ImageExtractor": {"window_width": 20, "window_shift": 3}})

    extractor = ImageExtractor.from_name(
        "LocalPeakWindowSum", subarray=subarray, config=config
    )
    assert extractor.window_width.tel[None] == 20
    assert extractor.window_shift.tel[None] == 3

    with pytest.warns(UserWarning):
        ImageExtractor.from_name("FullWaveformSum", config=config, subarray=subarray) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:16,代码来源:test_extractor.py

示例8: test_config

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config():
    """ check that components can be constructed by config dict """
    config = Config()
    config["ExampleComponent"] = Config()
    config["ExampleComponent"]["param"] = 199.0
    comp = ExampleComponent(config=config)
    assert comp.param == 199.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:9,代码来源:test_component.py

示例9: test_config_baseclass

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_baseclass():
    """ check that parent and subclass configuration works """
    config = Config()
    config["ExampleComponent"] = Config()
    config["ExampleComponent"]["param"] = 199.0
    comp1 = ExampleSubclass1(config=config)
    assert comp1.param == 199.0
    comp2 = ExampleSubclass2(config=config)
    assert comp2.param == 199.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:11,代码来源:test_component.py

示例10: test_config_subclass1

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_subclass1():
    """check sub-class config"""
    config = Config()
    config["ExampleSubclass1"] = Config()
    config["ExampleSubclass1"]["param"] = 199.0
    comp = ExampleComponent(config=config)
    assert comp.param == 1.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:9,代码来源:test_component.py

示例11: test_config_sibling1

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_sibling1():
    """ check sibling config """
    config = Config()
    config["ExampleSubclass1"] = Config()
    config["ExampleSubclass1"]["param"] = 199.0
    comp1 = ExampleSubclass1(config=config)
    assert comp1.param == 199.0
    comp2 = ExampleSubclass2(config=config)
    assert comp2.param == 3.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:11,代码来源:test_component.py

示例12: test_config_sibling2

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_sibling2():
    """ check sibling config """
    config = Config()
    config["ExampleSubclass2"] = Config()
    config["ExampleSubclass2"]["param"] = 199.0
    comp1 = ExampleSubclass1(config=config)
    assert comp1.param == 1.0
    comp2 = ExampleSubclass2(config=config)
    assert comp2.param == 199.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:11,代码来源:test_component.py

示例13: test_config_baseclass_then_subclass

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_baseclass_then_subclass():
    """ check base and subclass config """
    config = Config()
    config["ExampleComponent"] = Config()
    config["ExampleComponent"]["param"] = 199.0
    config["ExampleSubclass1"] = Config()
    config["ExampleSubclass1"]["param"] = 229.0
    comp = ExampleSubclass1(config=config)
    assert comp.param == 229.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:11,代码来源:test_component.py

示例14: test_config_subclass_then_baseclass

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_subclass_then_baseclass():
    """ check subclass and base config """
    config = Config()
    config["ExampleSubclass1"] = Config()
    config["ExampleSubclass1"]["param"] = 229.0
    config["ExampleComponent"] = Config()
    config["ExampleComponent"]["param"] = 199.0
    comp = ExampleSubclass1(config=config)
    assert comp.param == 229.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:11,代码来源:test_component.py

示例15: test_config_override

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import Config [as 别名]
def test_config_override():
    """ check that we can override a trait set in the config """
    config = Config()
    config["ExampleComponent"] = Config()
    config["ExampleComponent"]["param"] = 199.0
    comp = ExampleComponent(config=config, param=229.0)
    assert comp.param == 229.0 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:9,代码来源:test_component.py


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