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

xrange and izip_longest aren't available in vanilla python3 (#17226)

Fixes for these are either rewriting to get rid of the need for the
functions or using six.moves to get equivalent functions for both
python2 and python3
This commit is contained in:
Toshio Kuratomi 2016-08-24 12:28:02 -07:00 committed by GitHub
parent 27b0f3241b
commit 51ec35378d
4 changed files with 7 additions and 6 deletions

View file

@ -218,7 +218,7 @@ class DocCLI(CLI):
text.append("- name: %s" % (desc)) text.append("- name: %s" % (desc))
text.append(" action: %s" % (doc['module'])) text.append(" action: %s" % (doc['module']))
pad = 31 pad = 31
subdent = ''.join([" " for a in xrange(pad)]) subdent = " " * pad
limit = display.columns - pad limit = display.columns - pad
for o in sorted(doc['options'].keys()): for o in sorted(doc['options'].keys()):

View file

@ -26,14 +26,14 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
import itertools
import re import re
import time
import itertools
import shlex import shlex
import itertools import time
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
from ansible.module_utils.six.moves import zip_longest
DEFAULT_COMMENT_TOKENS = ['#', '!', '/*', '*/'] DEFAULT_COMMENT_TOKENS = ['#', '!', '/*', '*/']
@ -98,7 +98,7 @@ def ignore_line(text, tokens=None):
def get_next(iterable): def get_next(iterable):
item, next_item = itertools.tee(iterable, 2) item, next_item = itertools.tee(iterable, 2)
next_item = itertools.islice(next_item, 1, None) next_item = itertools.islice(next_item, 1, None)
return itertools.izip_longest(item, next_item) return zip_longest(item, next_item)
def parse(lines, indent, comment_tokens=None): def parse(lines, indent, comment_tokens=None):
toplevel = re.compile(r'\S') toplevel = re.compile(r'\S')

View file

@ -19,6 +19,7 @@ __metaclass__ = type
from re import compile as re_compile, IGNORECASE from re import compile as re_compile, IGNORECASE
from ansible.compat.six.moves import xrange
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.parsing.splitter import parse_kv from ansible.parsing.splitter import parse_kv
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase

View file

@ -17,7 +17,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: generate random string - name: generate random string
command: python -c "import string,random; print ''.join(random.choice(string.ascii_lowercase) for _ in xrange(8));" command: python -c "import string,random; print ''.join(random.choice(string.ascii_lowercase) for _ in range(8));"
register: random_string register: random_string
tags: tags:
- prepare - prepare