forked from TrueCloudLab/s3-tests
Adding unlimited=bool to files_varied -- if set to true, it will never issue StopIteration
This commit is contained in:
parent
43b2f8695d
commit
44cb2f256e
1 changed files with 7 additions and 6 deletions
|
@ -160,7 +160,7 @@ def names(mean, stddev, charset=None, seed=None):
|
||||||
name = ''.join(rand.choice(charset) for _ in xrange(length))
|
name = ''.join(rand.choice(charset) for _ in xrange(length))
|
||||||
yield name
|
yield name
|
||||||
|
|
||||||
def files_varied(groups):
|
def files_varied(groups, unlimited=False):
|
||||||
""" Yields a weighted-random selection of file-like objects. """
|
""" Yields a weighted-random selection of file-like objects. """
|
||||||
# Quick data type sanity.
|
# Quick data type sanity.
|
||||||
assert groups and isinstance(groups, (list, tuple))
|
assert groups and isinstance(groups, (list, tuple))
|
||||||
|
@ -193,12 +193,13 @@ def files_varied(groups):
|
||||||
num -= file_set.num
|
num -= file_set.num
|
||||||
continue
|
continue
|
||||||
|
|
||||||
total_num -= 1
|
if not unlimited:
|
||||||
file_set.num -= 1
|
total_num -= 1
|
||||||
|
file_set.num -= 1
|
||||||
|
|
||||||
# None left in this set!
|
# None left in this set!
|
||||||
if file_set.num == 0:
|
if file_set.num == 0:
|
||||||
file_sets.remove(file_set)
|
file_sets.remove(file_set)
|
||||||
|
|
||||||
ok = 1
|
ok = 1
|
||||||
yield next(file_set.files)
|
yield next(file_set.files)
|
||||||
|
|
Loading…
Add table
Reference in a new issue