Update flatten.py
This commit is contained in:
committed by
GitHub
parent
be21e606c3
commit
bcdf172982
+5
-3
@@ -7,7 +7,9 @@ from specklepy.objects import Base
|
||||
|
||||
def flatten_base(base: Base) -> Iterable[Base]:
|
||||
"""Take a base and flatten it to an iterable of bases."""
|
||||
if hasattr(base, "elements"):
|
||||
for element in base["elements"]:
|
||||
yield from flatten_base(element)
|
||||
if hasattr(base, "elements") and base.elements is not None:
|
||||
# Check if base.elements is not only present and non-None, but also an iterable
|
||||
if isinstance(base.elements, Iterable):
|
||||
for element in base.elements:
|
||||
yield from flatten_base(element)
|
||||
yield base
|
||||
|
||||
Reference in New Issue
Block a user