當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。