mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
* Add dict and list_to_dict filters.
* Remove list_to_dict filter.
* Add myself as maintainer.
(cherry picked from commit b6ae47c455
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
c72b337327
commit
92b388817f
5 changed files with 38 additions and 0 deletions
24
plugins/filter/dict.py
Normal file
24
plugins/filter/dict.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2021, Felix Fontein <felix@fontein.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
def dict_filter(sequence):
|
||||
'''Convert a list of tuples to a dictionary.
|
||||
|
||||
Example: ``[[1, 2], ['a', 'b']] | community.general.dict`` results in ``{1: 2, 'a': 'b'}``
|
||||
'''
|
||||
return dict(sequence)
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
'''Ansible jinja2 filters'''
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'dict': dict_filter,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue