From 1654a35766ed684fff15a5befedf789c0eb795bf Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 30 Mar 2004 08:32:55 +0000 Subject: [PATCH] Added trueCycle in preparation for the new registry stuff for multiple servers per network. --- src/fix.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/fix.py b/src/fix.py index feab576a3..4814fe37f 100644 --- a/src/fix.py +++ b/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):