Debian Codegraph @

lib/ansible/utils/listify.py

raw
1 # (c) 2014 Michael DeHaan, <[email protected]>
2 #
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17 from __future__ import annotations
18
19 from collections.abc import Iterable
20
21 from ansible.utils.display import Display
22
23 display = Display()
24
25 __all__ = ['listify_lookup_plugin_terms']
26
27
28 def listify_lookup_plugin_terms(terms, templar=None, fail_on_undefined=True):
29 # deprecated: description="Calling listify_lookup_plugin_terms function is not necessary; the function should be deprecated." core_version="2.23"
30 # display.deprecated(
31 # msg='The "listify_lookup_plugin_terms" function is not required for lookup terms to be templated.',
32 # version='2.27',
33 # help_text='If needed, implement custom `strip` or list-wrapping in the caller.',
34 # )
35
36 if isinstance(terms, str):
37 terms = terms.strip()
38
39 if isinstance(terms, str) or not isinstance(terms, Iterable):
40 terms = [terms]
41
42 return terms