oo_filters.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:origin-ci-tool 作者: openshift 项目源码 文件源码
def oo_select_keys(data, keys):
        """ This returns a list, which contains the value portions for the keys
            Ex: data = { 'a':1, 'b':2, 'c':3 }
                keys = ['a', 'c']
                returns [1, 3]
        """

        if not isinstance(data, Mapping):
            raise errors.AnsibleFilterError("|failed expects to filter on a dict or object")

        if not isinstance(keys, list):
            raise errors.AnsibleFilterError("|failed expects first param is a list")

        # Gather up the values for the list of keys passed in
        retval = [data[key] for key in keys if key in data]

        return retval
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号