mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +00:00
Option to yield progress from iterate() and consume_iterator()
This commit is contained in:
@@ -211,17 +211,20 @@ def create_shape(settings, inst, repr=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def consume_iterator(it):
|
def consume_iterator(it, with_progress=False):
|
||||||
if it.initialize():
|
if it.initialize():
|
||||||
while True:
|
while True:
|
||||||
yield it.get()
|
if with_progress:
|
||||||
|
yield it.progress(), it.get()
|
||||||
|
else:
|
||||||
|
yield it.get()
|
||||||
if not it.next():
|
if not it.next():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def iterate(settings, file_or_filename, num_threads=1, include=None, exclude=None):
|
def iterate(settings, file_or_filename, num_threads=1, include=None, exclude=None, with_progress=False):
|
||||||
it = iterator(settings, file_or_filename, num_threads, include, exclude)
|
it = iterator(settings, file_or_filename, num_threads, include, exclude)
|
||||||
yield from consume_iterator(it)
|
yield from consume_iterator(it, with_progress=with_progress)
|
||||||
|
|
||||||
|
|
||||||
def make_shape_function(fn):
|
def make_shape_function(fn):
|
||||||
|
|||||||
Reference in New Issue
Block a user