mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 02:32:42 +01:00
Added trueCycle in preparation for the new registry stuff for multiple servers per network.
This commit is contained in:
parent
cc9522e833
commit
1654a35766
15
src/fix.py
15
src/fix.py
@ -70,12 +70,23 @@ def window(L, size):
|
||||
yield L[i:i+size]
|
||||
|
||||
import itertools
|
||||
def ilen(iterator):
|
||||
def ilen(iterable):
|
||||
"""Returns the length of an iterator."""
|
||||
i = 0
|
||||
for _ in iterator:
|
||||
for _ in iterable:
|
||||
i += 1
|
||||
return i
|
||||
|
||||
def trueCycle(iterable):
|
||||
while 1:
|
||||
yielded = False
|
||||
for x in iterable:
|
||||
yield x
|
||||
yielded = True
|
||||
if not yielded:
|
||||
raise StopIteration
|
||||
|
||||
itertools.trueCycle = trueCycle
|
||||
itertools.ilen = ilen
|
||||
|
||||
def groupby(key, iterable):
|
||||
|
Loading…
Reference in New Issue
Block a user