本文整理匯總了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'
}
}
})