mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
geom.Iterate - fix incorrect typing, document some arguments #5299
This commit is contained in:
@@ -437,6 +437,8 @@ def consume_iterator(
|
||||
break
|
||||
|
||||
|
||||
# Overloads need to cover different return types
|
||||
# based on `with_progress` argument.
|
||||
@overload
|
||||
def iterate(
|
||||
settings: settings,
|
||||
@@ -445,7 +447,7 @@ def iterate(
|
||||
include: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
exclude: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
with_progress: Literal[False] = False,
|
||||
cache: Optional[serializers.hdf5] = None,
|
||||
cache: Optional[str] = None,
|
||||
serializer_settings: Optional[serializer_settings] = None,
|
||||
geometry_library: GEOMETRY_LIBRARY = "opencascade",
|
||||
) -> Generator[IteratorOutput, None, None]: ...
|
||||
@@ -457,7 +459,7 @@ def iterate(
|
||||
include: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
exclude: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
with_progress: Literal[True] = True,
|
||||
cache: Optional[serializers.hdf5] = None,
|
||||
cache: Optional[str] = None,
|
||||
serializer_settings: Optional[serializer_settings] = None,
|
||||
geometry_library: GEOMETRY_LIBRARY = "opencascade",
|
||||
) -> Generator[tuple[int, IteratorOutput], None, None]: ...
|
||||
@@ -469,7 +471,7 @@ def iterate(
|
||||
include: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
exclude: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
with_progress: bool = False,
|
||||
cache: Optional[serializers.hdf5] = None,
|
||||
cache: Optional[str] = None,
|
||||
serializer_settings: Optional[serializer_settings] = None,
|
||||
geometry_library: GEOMETRY_LIBRARY = "opencascade",
|
||||
) -> Generator[Union[IteratorOutput, tuple[int, IteratorOutput]], None, None]: ...
|
||||
@@ -480,12 +482,18 @@ def iterate(
|
||||
include: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
exclude: Optional[Union[list[entity_instance], list[str]]] = None,
|
||||
with_progress: bool = False,
|
||||
cache: Optional[serializers.hdf5] = None,
|
||||
cache: Optional[str] = None,
|
||||
serializer_settings: Optional[serializer_settings] = None,
|
||||
geometry_library: GEOMETRY_LIBRARY = "opencascade",
|
||||
) -> Generator[Union[IteratorOutput, tuple[int, IteratorOutput]], None, None]:
|
||||
"""Get a geometry iterator for the provided file.
|
||||
|
||||
:param cache: .h5 cache filepath (might not exist, will be created).
|
||||
:param serializer_settings: Settings for cache serializer. Required if `cache` is provided.
|
||||
"""
|
||||
it = iterator(settings, file_or_filename, num_threads, include, exclude, geometry_library)
|
||||
if cache:
|
||||
assert serializer_settings, "`serializer_settings` argument is not optional if `cache` is provided."
|
||||
hdf5_cache = serializers.hdf5(cache, settings, serializer_settings)
|
||||
it.set_cache(hdf5_cache)
|
||||
yield from consume_iterator(it, with_progress=with_progress)
|
||||
|
||||
Reference in New Issue
Block a user