當前位置: 首頁>>代碼示例>>Python>>正文


Python loader.Config方法代碼示例

本文整理匯總了Python中IPython.config.loader.Config方法的典型用法代碼示例。如果您正苦於以下問題:Python loader.Config方法的具體用法?Python loader.Config怎麽用?Python loader.Config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPython.config.loader的用法示例。


在下文中一共展示了loader.Config方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_autorestore

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_autorestore():
    ip.user_ns['foo'] = 95
    ip.magic('store foo')
    del ip.user_ns['foo']
    c = Config()
    c.StoreMagics.autorestore = False
    orig_config = ip.config
    try:
        ip.config = c
        ip.extension_manager.reload_extension('storemagic')
        nt.assert_not_in('foo', ip.user_ns)
        c.StoreMagics.autorestore = True
        ip.extension_manager.reload_extension('storemagic')
        nt.assert_equal(ip.user_ns['foo'], 95)
    finally:
        ip.config = orig_config 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:test_storemagic.py

示例2: test_custom

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_custom(self):
        config = Config()
        config.foo = 'foo'
        config.bar = 'bar'
        c1 = Configurable(config=config)
        c2 = Configurable(config=c1.config)
        c3 = Configurable(config=c2.config)
        self.assertEqual(c1.config, config)
        self.assertEqual(c2.config, config)
        self.assertEqual(c3.config, config)
        # Test that copies are not made
        self.assertTrue(c1.config is config)
        self.assertTrue(c2.config is config)
        self.assertTrue(c3.config is config)
        self.assertTrue(c1.config is c2.config)
        self.assertTrue(c2.config is c3.config) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:test_configurable.py

示例3: test_multi_parent

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_multi_parent(self):
        cfg = Config({
            'MyParent2' : {
                'MyParent' : {
                    'MyConfigurable' : {
                        'b' : 2.0,
                    }
                },
                # this one shouldn't count
                'MyConfigurable' : {
                    'b' : 3.0,
                },
            }
        })
        parent2 = MyParent2(config=cfg)
        parent = MyParent(parent=parent2)
        myc = MyConfigurable(parent=parent)
        self.assertEqual(myc.b, parent.config.MyParent2.MyParent.MyConfigurable.b) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:test_configurable.py

示例4: test_parent_priority

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_parent_priority(self):
        cfg = Config({
            'MyConfigurable' : {
                'b' : 2.0,
            },
            'MyParent' : {
                'MyConfigurable' : {
                    'b' : 3.0,
                }
            },
            'MyParent2' : {
                'MyConfigurable' : {
                    'b' : 4.0,
                }
            }
        })
        parent = MyParent2(config=cfg)
        myc = MyConfigurable(parent=parent)
        self.assertEqual(myc.b, parent.config.MyParent2.MyConfigurable.b) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:test_configurable.py

示例5: test_omit__names

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_omit__names():
    # also happens to test IPCompleter as a configurable
    ip = get_ipython()
    ip._hidden_attr = 1
    c = ip.Completer
    ip.ex('ip=get_ipython()')
    cfg = Config()
    cfg.IPCompleter.omit__names = 0
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_true('ip.__str__' in matches)
    nt.assert_true('ip._hidden_attr' in matches)
    cfg.IPCompleter.omit__names = 1
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_false('ip.__str__' in matches)
    nt.assert_true('ip._hidden_attr' in matches)
    cfg.IPCompleter.omit__names = 2
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_false('ip.__str__' in matches)
    nt.assert_false('ip._hidden_attr' in matches)
    del ip._hidden_attr 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:25,代碼來源:test_completer.py

示例6: main

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    settings = get_appsettings(config_uri)
    engine = create_engine('pyvac', settings, scoped=False)

    config = Configurator(settings=settings)
    config.end()

    from pyvac.models import (Base, Permission, Group, User, Request, # noqa
                              Countries, VacationType, PasswordRecovery,
                              Sudoer, CPVacation, RTTVacation,
                              RequestHistory, Pool, UserPool)

    session = DBSession()
    try:
        from IPython import embed
        from IPython.config.loader import Config
        cfg = Config()
        cfg.InteractiveShellEmbed.confirm_exit = False
        embed(config=cfg, banner1="Welcome to pyvac shell.")
    except ImportError:
        import code
        code.interact("pyvac shell", local=locals()) 
開發者ID:sayoun,項目名稱:pyvac,代碼行數:27,代碼來源:shell.py

示例7: Shell

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.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

示例8: _get_tcp_km

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def _get_tcp_km(self):
        c = Config()
        km = KernelManager(config=c)
        return km 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:test_kernelmanager.py

示例9: _get_ipc_km

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def _get_ipc_km(self):
        c = Config()
        c.KernelManager.transport = 'ipc'
        c.KernelManager.ip = 'test'
        km = KernelManager(config=c)
        return km 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:test_kernelmanager.py

示例10: _get_tcp_km

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def _get_tcp_km(self):
        c = Config()
        km = MultiKernelManager(config=c)
        return km 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:test_multikernelmanager.py

示例11: test_flatten_flags

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_flatten_flags(self):
        cfg = Config()
        cfg.MyApp.log_level = logging.WARN
        app = MyApp()
        app.update_config(cfg)
        self.assertEqual(app.log_level, logging.WARN)
        self.assertEqual(app.config.MyApp.log_level, logging.WARN)
        app.initialize(["--crit"])
        self.assertEqual(app.log_level, logging.CRITICAL)
        # this would be app.config.Application.log_level if it failed:
        self.assertEqual(app.config.MyApp.log_level, logging.CRITICAL) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:test_application.py

示例12: test_flatten_aliases

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_flatten_aliases(self):
        cfg = Config()
        cfg.MyApp.log_level = logging.WARN
        app = MyApp()
        app.update_config(cfg)
        self.assertEqual(app.log_level, logging.WARN)
        self.assertEqual(app.config.MyApp.log_level, logging.WARN)
        app.initialize(["--log-level", "CRITICAL"])
        self.assertEqual(app.log_level, logging.CRITICAL)
        # this would be app.config.Application.log_level if it failed:
        self.assertEqual(app.config.MyApp.log_level, "CRITICAL") 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:13,代碼來源:test_application.py

示例13: test_inheritance

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_inheritance(self):
        config = Config()
        config.MyConfigurable.a = 2
        config.MyConfigurable.b = 2.0
        c1 = MyConfigurable(config=config)
        c2 = MyConfigurable(config=c1.config)
        self.assertEqual(c1.a, config.MyConfigurable.a)
        self.assertEqual(c1.b, config.MyConfigurable.b)
        self.assertEqual(c2.a, config.MyConfigurable.a)
        self.assertEqual(c2.b, config.MyConfigurable.b) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:test_configurable.py

示例14: test_parent

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_parent(self):
        config = Config()
        config.Foo.a = 10
        config.Foo.b = "wow"
        config.Bar.b = 'later'
        config.Bar.c = 100.0
        f = Foo(config=config)
        b = Bar(config=f.config)
        self.assertEqual(f.a, 10)
        self.assertEqual(f.b, 'wow')
        self.assertEqual(b.b, 'gotit')
        self.assertEqual(b.c, 100.0) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:14,代碼來源:test_configurable.py

示例15: test_override2

# 需要導入模塊: from IPython.config import loader [as 別名]
# 或者: from IPython.config.loader import Config [as 別名]
def test_override2(self):
        config = Config()
        config.Foo.a = 1
        config.Bar.b = 'or'  # Up above b is config=False, so this won't do it.
        config.Bar.c = 10.0
        c = Bar(config=config)
        self.assertEqual(c.a, config.Foo.a)
        self.assertEqual(c.b, 'gotit')
        self.assertEqual(c.c, config.Bar.c)
        c = Bar(a=2, b='and', c=20.0, config=config)
        self.assertEqual(c.a, 2)
        self.assertEqual(c.b, 'and')
        self.assertEqual(c.c, 20.0) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:test_configurable.py


注:本文中的IPython.config.loader.Config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。