本文整理汇总了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
示例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)
示例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)
示例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)
示例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
示例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())
示例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
示例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
示例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
示例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
示例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)
示例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")
示例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)
示例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)
示例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)