Separate out consume_iterator()

This commit is contained in:
Thomas Krijnen
2021-10-23 21:34:25 +02:00
committed by GitHub
parent 7bccf10fec
commit 4733c82b82
@@ -210,8 +210,7 @@ def create_shape(settings, inst, repr=None):
) )
def iterate(settings, file_or_filename, num_threads=1, include=None, exclude=None): def consume_iterator(it):
it = iterator(settings, file_or_filename, num_threads, include, exclude)
if it.initialize(): if it.initialize():
while True: while True:
yield it.get() yield it.get()
@@ -219,6 +218,11 @@ def iterate(settings, file_or_filename, num_threads=1, include=None, exclude=Non
break break
def iterate(settings, file_or_filename, num_threads=1, include=None, exclude=None):
it = iterator(settings, file_or_filename, num_threads, include, exclude)
yield from consume_iterator(it)
def make_shape_function(fn): def make_shape_function(fn):
def entity_instance_or_none(e): def entity_instance_or_none(e):
return None if e is None else entity_instance(e) return None if e is None else entity_instance(e)