From 4935246c7b412a87e9a1100e398705a868095db3 Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Thu, 2 Oct 2014 13:09:21 -0400 Subject: Added oo_len filter --- filter_plugins/oo_filters.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 0c34cfc3e..77abfb2a4 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -9,6 +9,12 @@ def oo_pdb(arg): pdb.set_trace() return arg +def oo_len(arg): + ''' This returns the size of the argument + Ex: "{{ hostvars | oo_size }}" + ''' + return len(arg) + def get_attr(data, attribute=None): ''' This looks up dictionary attributes of the form a.b.c and returns the value. Ex: data = {'a': {'b': {'c': 5}}} @@ -65,5 +71,6 @@ class FilterModule (object): return { "oo_select_keys": oo_select_keys, "oo_collect": oo_collect, + "oo_len": oo_len, "oo_pdb": oo_pdb } -- cgit v1.2.3