From 2a62f3f207f665374c39a143e39b4f7e62e02e24 Mon Sep 17 00:00:00 2001 From: gryf Date: Fri, 7 Aug 2020 12:43:33 +0200 Subject: [PATCH] Fix forgotten import for zip_longest. During transition from 2to3, izip_longest was renamed to zip_longest, but there is no import from itertools. In this commit we fixed that, also removed not needed izip_longest function. --- wicd/misc.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/wicd/misc.py b/wicd/misc.py index f070bb8..fdd8b3a 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -22,7 +22,7 @@ throughout wicd. # along with this program. If not, see . # -from itertools import repeat, chain +import itertools import locale import os import re @@ -661,27 +661,6 @@ def timeout_add(time, func, milli=False): return gobject.timeout_add(time, func) -def izip_longest(*args, **kwds): - """Implement the itertools.izip_longest method. - - We implement the method here because its new in Python 2.6. - - """ - # izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D- - fillvalue = kwds.get('fillvalue') - - def sentinel(counter=([fillvalue]*(len(args)-1)).pop): - yield counter() # yields the fillvalue, or raises IndexError - - fillers = repeat(fillvalue) - iters = [chain(it, sentinel(), fillers) for it in args] - try: - for tup in zip(*iters): - yield tup - except IndexError: - pass - - def grouper(n, iterable, fillvalue=None): """Iterate over several elements at once @@ -689,4 +668,4 @@ def grouper(n, iterable, fillvalue=None): """ args = [iter(iterable)] * n - return zip_longest(fillvalue=fillvalue, *args) + return itertools.zip_longest(fillvalue=fillvalue, *args)