本文整理汇总了Python中bottle.ConfigDict.load_dict方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDict.load_dict方法的具体用法?Python ConfigDict.load_dict怎么用?Python ConfigDict.load_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle.ConfigDict
的用法示例。
在下文中一共展示了ConfigDict.load_dict方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_issue588
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_issue588(self):
"""`ConfigDict` namespaces break route options"""
c = ConfigDict()
c.load_dict({'a': {'b': 'c'}}, make_namespaces=True)
self.assertEqual('c', c['a.b'])
self.assertEqual('c', c['a']['b'])
self.assertEqual({'b': 'c'}, c['a'])
示例2: test_load_dict
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_load_dict(self):
c = ConfigDict()
d = dict(a=dict(b=dict(foo=5, bar=6), baz=7))
c.load_dict(d)
self.assertEqual(c['a.b.foo'], 5)
self.assertEqual(c['a.b.bar'], 6)
self.assertEqual(c['a.baz'], 7)
示例3: test_issue720
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_issue720(self):
"""Accept unicode keys."""
try:
key = unichr(12354)
except NameError:
key = chr(12354)
c = ConfigDict()
c.load_dict({key: 'value'})
self.assertEqual('value', c[key])
c = ConfigDict()
c.load_dict({key: {'subkey': 'value'}})
self.assertEqual('value', c[key + '.subkey'])
示例4: test_load_dict
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_load_dict(self):
c = ConfigDict()
d = dict(a=dict(b=dict(foo=5, bar=6), baz=7))
c.load_dict(d)
self.assertEqual(c['a.b.foo'], 5)
self.assertEqual(c['a.b.bar'], 6)
self.assertEqual(c['a.baz'], 7)
# unicode keys (see issue #720)
try:
key = unichr(12354)
except NameError:
key = chr(12354)
c = ConfigDict()
c.load_dict({key: 'value'})
self.assertEqual('value', c[key])
c = ConfigDict()
c.load_dict({key: {'subkey': 'value'}})
self.assertEqual('value', c[key + '.subkey'])
示例5: test_string_key_only
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_string_key_only(self):
c = ConfigDict()
self.assertRaises(TypeError, lambda: setitem(c, 5, 6))
self.assertRaises(TypeError, lambda: c.load_dict({5:6}))
示例6: test_string_save_keys
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
def test_string_save_keys(self):
c = ConfigDict()
with self.assertRaises(TypeError):
c[5] = 'value'
with self.assertRaises(TypeError):
c.load_dict({5: 'value'})
示例7: ConfigDict
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import load_dict [as 别名]
app_config = ConfigDict()
app_config.load_dict({
'app': {
'debug': True,
'timezone': 'Europe/Moscow',
'server': 'tornado',
'port': 5040,
'auth': {
'admin': '$2a$10$YOUR-BCRYPT-HASH'
},
'db': {
'path': './data/sqlite.db'
}
},
'blog': {
'label': {'read_more': 'Read full article'},
'html_parser': 'lxml', # you must install 'lxml' package or use 'html.parser' instead
},
'feed': {
'author': 'Nikita Dementev',
'title': 'Neutral notes',
'subtitle': 'О коде и погоде',
},
'deploy': {
'production': {
'host': '[email protected]',
'key_file': '~/.ssh/same_rsa',
'target_dir': '~/www/example.com'
}
}
})