Private
Public Access
2
0

dev #16

Merged
seb merged 29 commits from dev into main 2026-02-12 16:24:52 +01:00
Showing only changes of commit 17a52312dd - Show all commits

View File

@@ -0,0 +1,52 @@
#!/usr/bin/python
DOCUMENTATION = r"""
name: listadddel
short_description: This filter add and remove items to/from a list.
version_added: "0.2.2"
author: Sébastien Namèche (@seb4itik)
description:
- If my_list is ["un", "deux", "trois"], then:
- {{ my_list | listadddel(["quatre", "cinq"], ["un"]) }}
- will produce:
- ["deux", "trois", "quatre", "cinq"]
options:
_input:
description: A list of strings.
type: list
elements: str
required: true
add:
description: A list of string to add to _input.
type: list
elements: str
default: []
delete:
description: A list of string to remove from _input.
type: list
elements: str
default: []
notes:
- delete is tronger than add. If the string is present in both delete and
add, it will not be in returned list.
"""
RETURN = r"""
_value:
type: list
elements: str
description:
- List of strings with new and removed elements.
"""
class FilterModule(object):
def filters(self):
return {
'listadddel': self.listadddel
}
def listadddel(self, l, add=[], delete=[]):
return [e for e in l+add if e not in delete]