mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
util.get_work_schedule_tasks - fix critical bug with missing root tasks
Now we also use generator to mirror get_schedule_cost_items
This commit is contained in:
@@ -21,7 +21,7 @@ import ifcopenshell.util.date
|
||||
from math import floor
|
||||
from functools import cache
|
||||
from typing import Union, Literal, Optional
|
||||
from collections.abc import Iterator
|
||||
from collections.abc import Generator
|
||||
|
||||
|
||||
DURATION_TYPE = Literal["ELAPSEDTIME", "WORKTIME", "NOTDEFINED"]
|
||||
@@ -289,18 +289,17 @@ def get_parent_task(task: ifcopenshell.entity_instance) -> Union[ifcopenshell.en
|
||||
return obj
|
||||
|
||||
|
||||
def get_all_nested_tasks(task: ifcopenshell.entity_instance) -> Iterator[ifcopenshell.entity_instance]:
|
||||
def get_all_nested_tasks(task: ifcopenshell.entity_instance) -> Generator[ifcopenshell.entity_instance]:
|
||||
for nested_task in get_nested_tasks(task):
|
||||
yield nested_task
|
||||
yield from get_all_nested_tasks(nested_task)
|
||||
|
||||
|
||||
def get_work_schedule_tasks(work_schedule: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
tasks = []
|
||||
def get_work_schedule_tasks(work_schedule: ifcopenshell.entity_instance) -> Generator[ifcopenshell.entity_instance]:
|
||||
"""Get all work schedule tasks, including the nested ones."""
|
||||
for root_task in get_root_tasks(work_schedule):
|
||||
nested_tasks = get_all_nested_tasks(root_task)
|
||||
tasks.extend(nested_tasks)
|
||||
return tasks
|
||||
yield root_task
|
||||
yield from get_all_nested_tasks(root_task)
|
||||
|
||||
|
||||
def get_root_tasks(work_schedule: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
|
||||
Reference in New Issue
Block a user