Cleanup netcli (#17529)

This honestly mostly amounts to Python 3 fixes.
pull/17530/head
Nathaniel Case 8 years ago committed by GitHub
parent bf29961947
commit bfe341177b

@ -28,11 +28,11 @@
import re import re
import time import time
import itertools
import shlex import shlex
from ansible.module_utils.basic import BOOLEANS_TRUE, BOOLEANS_FALSE from ansible.module_utils.basic import BOOLEANS_TRUE, BOOLEANS_FALSE
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types, text_type
from ansible.module_utils.six.moves import zip
def to_list(val): def to_list(val):
if isinstance(val, (list, tuple)): if isinstance(val, (list, tuple)):
@ -83,7 +83,7 @@ class Cli(object):
def run_commands(self): def run_commands(self):
responses = self.connection.run_commands(self._commands) responses = self.connection.run_commands(self._commands)
for resp, cmd in itertools.izip(responses, self._commands): for resp, cmd in zip(responses, self._commands):
cmd.response = resp cmd.response = resp
# wipe out the commands list to avoid issues if additional # wipe out the commands list to avoid issues if additional
@ -189,7 +189,7 @@ class Conditional(object):
key, op, val = shlex.split(conditional) key, op, val = shlex.split(conditional)
self.key = key self.key = key
self.func = self.func(op) self.func = self._func(op)
self.value = self._cast_value(val) self.value = self._cast_value(val)
def __call__(self, data): def __call__(self, data):
@ -206,9 +206,9 @@ class Conditional(object):
elif re.match(r'^\d+$', value): elif re.match(r'^\d+$', value):
return int(value) return int(value)
else: else:
return unicode(value) return text_type(value)
def func(self, oper): def _func(self, oper):
for func, operators in self.OPERATORS.items(): for func, operators in self.OPERATORS.items():
if oper in operators: if oper in operators:
return getattr(self, func) return getattr(self, func)

Loading…
Cancel
Save