From afe30a663302d26c686964d31e66be83b646af4b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 19 Nov 2013 00:06:38 -0500 Subject: [PATCH 1/3] added difference and symetric difference filters Signed-off-by: Brian Coca --- lib/ansible/runner/filter_plugins/core.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index b86abae42a6..55bd5876fe2 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -126,6 +126,12 @@ def unique(a): def intersect(a, b): return set(a).intersection(b) +def difference(a, b): + return set(a).difference(b) + +def symetric_difference(a, b): + return set(a).symetric_difference(b) + class FilterModule(object): ''' Ansible core jinja2 filters ''' @@ -183,5 +189,7 @@ class FilterModule(object): # list 'unique' : unique, 'intersect': intersect, + 'difference': difference, + 'symetric_difference': symetric_difference, } - + From 460bbfaec10481af09084a297d6555c6ee09b814 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 19 Nov 2013 14:40:55 -0500 Subject: [PATCH 2/3] added union filter Signed-off-by: Brian Coca --- lib/ansible/runner/filter_plugins/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index 55bd5876fe2..0583745248d 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -132,6 +132,9 @@ def difference(a, b): def symetric_difference(a, b): return set(a).symetric_difference(b) +def union(a, b): + return set(a).union(b) + class FilterModule(object): ''' Ansible core jinja2 filters ''' @@ -191,5 +194,6 @@ class FilterModule(object): 'intersect': intersect, 'difference': difference, 'symetric_difference': symetric_difference, + 'union': union, } From 34c33f7ea1c762a3c48f3d1ab98a31809e04bde2 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 19 Nov 2013 14:48:11 -0500 Subject: [PATCH 3/3] now correctly spell symmetric Signed-off-by: Brian Coca --- lib/ansible/runner/filter_plugins/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index 0583745248d..495e17e2fa0 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -129,8 +129,8 @@ def intersect(a, b): def difference(a, b): return set(a).difference(b) -def symetric_difference(a, b): - return set(a).symetric_difference(b) +def symmetric_difference(a, b): + return set(a).symmetric_difference(b) def union(a, b): return set(a).union(b) @@ -193,7 +193,7 @@ class FilterModule(object): 'unique' : unique, 'intersect': intersect, 'difference': difference, - 'symetric_difference': symetric_difference, + 'symmetric_difference': symmetric_difference, 'union': union, }