本文整理匯總了Python中utils.AttributeDict.update方法的典型用法代碼示例。如果您正苦於以下問題:Python AttributeDict.update方法的具體用法?Python AttributeDict.update怎麽用?Python AttributeDict.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.AttributeDict
的用法示例。
在下文中一共展示了AttributeDict.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _load_extends_settings
# 需要導入模塊: from utils import AttributeDict [as 別名]
# 或者: from utils.AttributeDict import update [as 別名]
def _load_extends_settings(self, section_name, store):
"""
Loads all settings from other template(s) specified by a section's
'extends' setting.
This method walks a dependency tree of sections from bottom up. Each
step is a group of settings for a section in the form of a dictionary.
A 'master' dictionary is updated with the settings at each step. This
causes the next group of settings to override the previous, and so on.
The 'section_name' settings are at the top of the dependency tree.
"""
section = store[section_name]
extends = section.get('extends')
if extends is None:
return
if DEBUG_CONFIG:
log.debug('%s extends %s' % (section_name, extends))
extensions = [section]
while True:
extends = section.get('extends', None)
if not extends:
break
try:
section = store[extends]
if section in extensions:
exts = ', '.join([self._get_section_name(x['__name__'])
for x in extensions])
raise exception.ConfigError(
"Cyclical dependency between sections %s. "
"Check your EXTENDS settings." % exts)
extensions.insert(0, section)
except KeyError:
raise exception.ConfigError(
"%s can't extend non-existent section %s" %
(section_name, extends))
transform = AttributeDict()
for extension in extensions:
transform.update(extension)
store[section_name] = transform