diff options
author | Felix Fontein <felix@fontein.de> | 2021-03-28 03:28:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 03:28:28 +0200 |
commit | af7f3fc2668b4f5fa58b47149ac16bf1d1135f62 (patch) | |
tree | 3f0d36768382544de010366258f020ebaf12a822 | |
parent | Temporarily disable strategy units (#74048) (diff) | |
download | ansible-af7f3fc2668b4f5fa58b47149ac16bf1d1135f62.tar.xz ansible-af7f3fc2668b4f5fa58b47149ac16bf1d1135f62.zip |
Revert "Add duplicated set filter and documentation (#72729)" (#74053)
This reverts commit 99a6627c60d8734d90f6982107eebb9de24ba54d.
* ci_complete
-rw-r--r-- | changelogs/fragments/72729-add-filter-duplicated.yml | 3 | ||||
-rw-r--r-- | docs/docsite/rst/user_guide/playbooks_filters.rst | 8 | ||||
-rw-r--r-- | lib/ansible/plugins/filter/mathstuff.py | 7 | ||||
-rw-r--r-- | test/units/plugins/filter/test_mathstuff.py | 8 |
4 files changed, 0 insertions, 26 deletions
diff --git a/changelogs/fragments/72729-add-filter-duplicated.yml b/changelogs/fragments/72729-add-filter-duplicated.yml deleted file mode 100644 index 949184c8e2..0000000000 --- a/changelogs/fragments/72729-add-filter-duplicated.yml +++ /dev/null @@ -1,3 +0,0 @@ -minor_changes: - - add filter duplicated that will return duplicate items from a list. - (https://github.com/ansible/ansible/pull/72729/) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 9ea4104440..984de55e4b 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -978,14 +978,6 @@ To get the symmetric difference of 2 lists (items exclusive to each list):: {{ list1 | symmetric_difference(list2) }} # => [10, 11, 99] -To get the duplicate values from a list (the resulting list contains unique duplicates):: - -.. versionadded:: 2.11 - - # list1: [1, 2, 5, 1, 3, 4, 10, 'a', 'z', 'a'] - {{ list1 | duplicated }} - # => [1, 'a'] - .. _math_stuff: Calculating numbers (math) diff --git a/lib/ansible/plugins/filter/mathstuff.py b/lib/ansible/plugins/filter/mathstuff.py index 52deb37fdf..77baa7ef00 100644 --- a/lib/ansible/plugins/filter/mathstuff.py +++ b/lib/ansible/plugins/filter/mathstuff.py @@ -26,7 +26,6 @@ __metaclass__ = type import itertools import math -from collections import Counter from jinja2.filters import environmentfilter from ansible.errors import AnsibleFilterError, AnsibleFilterTypeError @@ -88,11 +87,6 @@ def unique(environment, a, case_sensitive=False, attribute=None): @environmentfilter -def duplicated(environment, a): - return [k for k, v in Counter(a).items() if v > 1] - - -@environmentfilter def intersect(environment, a, b): if isinstance(a, Hashable) and isinstance(b, Hashable): c = set(a) & set(b) @@ -263,7 +257,6 @@ class FilterModule(object): # set theory 'unique': unique, - 'duplicated': duplicated, 'intersect': intersect, 'difference': difference, 'symmetric_difference': symmetric_difference, diff --git a/test/units/plugins/filter/test_mathstuff.py b/test/units/plugins/filter/test_mathstuff.py index ec4d5be034..d44a714669 100644 --- a/test/units/plugins/filter/test_mathstuff.py +++ b/test/units/plugins/filter/test_mathstuff.py @@ -180,11 +180,3 @@ class TestRekeyOnMember(): list_original = ({'proto': 'eigrp', 'id': 1}, {'proto': 'ospf', 'id': 2}, {'proto': 'eigrp', 'id': 3}) expected = {'eigrp': {'proto': 'eigrp', 'id': 3}, 'ospf': {'proto': 'ospf', 'id': 2}} assert ms.rekey_on_member(list_original, 'proto', duplicates='overwrite') == expected - - -class TestDuplicated: - def test_empty(self): - assert ms.duplicated(env, []) == [] - - def test_numbers(self): - assert ms.duplicated(env, [1, 3, 5, 5]) == [5] |