mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 04:20:22 +01:00
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.
This commit is contained in:
25
wicd/misc.py
25
wicd/misc.py
@@ -22,7 +22,7 @@ throughout wicd.
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
from itertools import repeat, chain
|
import itertools
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -661,27 +661,6 @@ def timeout_add(time, func, milli=False):
|
|||||||
return gobject.timeout_add(time, func)
|
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):
|
def grouper(n, iterable, fillvalue=None):
|
||||||
"""Iterate over several elements at once
|
"""Iterate over several elements at once
|
||||||
|
|
||||||
@@ -689,4 +668,4 @@ def grouper(n, iterable, fillvalue=None):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
args = [iter(iterable)] * n
|
args = [iter(iterable)] * n
|
||||||
return zip_longest(fillvalue=fillvalue, *args)
|
return itertools.zip_longest(fillvalue=fillvalue, *args)
|
||||||
|
|||||||
Reference in New Issue
Block a user