1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Treat generators like lists and tuples

This commit is contained in:
Henry Finucane 2015-06-29 14:55:11 -07:00
parent a77b58e351
commit 2d1cb7f328

View file

@ -16,6 +16,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from functools import partial from functools import partial
import types
try: try:
import netaddr import netaddr
@ -319,7 +320,7 @@ def ipaddr(value, query = '', version = False, alias = 'ipaddr'):
return False return False
# Check if value is a list and parse each element # Check if value is a list and parse each element
elif isinstance(value, (list, tuple)): elif isinstance(value, (list, tuple, types.GeneratorType)):
_ret = [] _ret = []
for element in value: for element in value:
@ -457,7 +458,7 @@ def ipaddr(value, query = '', version = False, alias = 'ipaddr'):
def ipwrap(value, query = ''): def ipwrap(value, query = ''):
try: try:
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple, types.GeneratorType)):
_ret = [] _ret = []
for element in value: for element in value:
if ipaddr(element, query, version = False, alias = 'ipwrap'): if ipaddr(element, query, version = False, alias = 'ipwrap'):