From 79fbe09a4dec0df6667bd5147c3c1852c7596d35 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 8 Feb 2018 16:30:51 -0500 Subject: [PATCH] remove slice filter as it already exists in jinja (#35922) --- lib/ansible/plugins/filter/core.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index b471c16a7c..d3f2e1424c 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -488,22 +488,6 @@ def flatten(mylist, levels=None): return ret -def dict_slice(mydict, keys): - ''' takes a dictionary and a list of keys and returns a list of values corresponding to those keys, if they exist ''' - - if not isinstance(mydict, MutableMapping): - raise AnsibleFilterError("The slice filter requires a mapping to operate on, got a %s." % type(mydict)) - - if not isinstance(keys, MutableSequence): - - if isinstance(keys, string_types): - keys = [keys] - else: - AnsibleFilterError("The slice filter requires a key or list of keys, got %s instead." % type(keys)) - - return [mydict[key] for key in keys if key in mydict] - - class FilterModule(object): ''' Ansible core jinja2 filters ''' @@ -590,5 +574,4 @@ class FilterModule(object): 'combine': combine, 'extract': extract, 'flatten': flatten, - 'slice': dict_slice, }