当前位置: 首页>>代码示例>>Python>>正文


Python OrderedDict.pop方法代码示例

本文整理汇总了Python中salt.utils.odict.OrderedDict.pop方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.pop方法的具体用法?Python OrderedDict.pop怎么用?Python OrderedDict.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在salt.utils.odict.OrderedDict的用法示例。


在下文中一共展示了OrderedDict.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_local_registry

# 需要导入模块: from salt.utils.odict import OrderedDict [as 别名]
# 或者: from salt.utils.odict.OrderedDict import pop [as 别名]
def get_local_registry(name,
                       cached=True,
                       cachetime=60,
                       registry_format='yaml'):
    '''Get local registry
    Masteralt & Salt share the local registries
    unless for the main ones:

        - controllers
        - services
        - nodetypes
        - localsettings
        - cloud

    For backward compatibility, we take care to load and merge
    shared registries in mastersalt & salt prefix if any is found.
    '''
    not_shared = ['controllers', 'services', 'nodetypes',
                  'localsettings', 'cloud']
    mastersalt_registryf = '{0}/makina-states/{1}.{2}'.format(
        '/etc/mastersalt',  name, registry_format)
    salt_registryf = '{0}/makina-states/{1}.{2}'.format(
        '/etc/salt',  name, registry_format)
    shared_registryf = os.path.join(
        '/etc/makina-states/{0}.{1}'.format(name, registry_format))
    registry = OrderedDict()
    # cache local registries one minute
    pkey = '{0}____'.format(name)
    key = '{0}{1}'.format(pkey, time.time() // cachetime)
    if name not in not_shared:
        to_load = [mastersalt_registryf,
                   salt_registryf,
                   shared_registryf]
    else:
        to_load = [
            '{0}/makina-states/{1}.{2}'.format(
                __opts__['config_dir'], name, registry_format)
        ]
    if (key not in _LOCAL_REG_CACHE) or (not cached):
        invalidate_cached_registry(name)
        for registryf in to_load:
            dregistry = os.path.dirname(registryf)
            if not os.path.exists(dregistry):
                os.makedirs(dregistry)
            if os.path.exists(registryf):
                _LOCAL_REG_CACHE[key] = registry = __salt__[
                    'mc_utils.dictupdate'](
                        registry,
                        __salt__[
                            'mc_macros.{0}_load_local_registry'.format(
                                registry_format)](name, registryf))
                # unprefix local simple registries
                loc_k = DEFAULT_LOCAL_REG_NAME.format(name)
                for k in [t for t in registry if t.startswith(loc_k)]:
                    spl = loc_k + '.'
                    nk = spl.join(k.split(spl)[1:])
                    registry[nk] = registry[k]
                    registry.pop(k)
    elif cached:
        registry = _LOCAL_REG_CACHE[key]
    return registry
开发者ID:jpcw,项目名称:makina-states,代码行数:63,代码来源:mc_macros.py


注:本文中的salt.utils.odict.OrderedDict.pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。