mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
black format
This commit is contained in:
@@ -158,6 +158,7 @@ def unserialise_cost_value(formula, cost_value):
|
||||
map_element_to_result(cost_value, result)
|
||||
return result
|
||||
|
||||
|
||||
def get_cost_items_for_product(product):
|
||||
"""
|
||||
Returns a list of cost items related to the given product.
|
||||
@@ -174,6 +175,7 @@ def get_cost_items_for_product(product):
|
||||
cost_items.append(assignment.RelatingControl)
|
||||
return cost_items
|
||||
|
||||
|
||||
def get_root_cost_items(cost_schedule):
|
||||
return [
|
||||
related_object
|
||||
@@ -182,22 +184,26 @@ def get_root_cost_items(cost_schedule):
|
||||
if related_object.is_a("IfcCostItem")
|
||||
]
|
||||
|
||||
|
||||
def get_all_nested_cost_items(cost_item):
|
||||
for cost_item in get_nested_cost_items(cost_item):
|
||||
yield cost_item
|
||||
yield from get_all_nested_cost_items(cost_item)
|
||||
|
||||
|
||||
def get_nested_cost_items(cost_item, is_deep=False):
|
||||
if is_deep:
|
||||
return list(get_all_nested_cost_items(cost_item))
|
||||
else:
|
||||
return [obj for rel in cost_item.IsNestedBy for obj in rel.RelatedObjects]
|
||||
|
||||
|
||||
def get_schedule_cost_items(cost_schedule):
|
||||
for cost_item in get_root_cost_items(cost_schedule):
|
||||
yield cost_item
|
||||
yield from get_all_nested_cost_items(cost_item)
|
||||
|
||||
|
||||
def get_cost_assignments_by_type(cost_item, filter_by_type=None):
|
||||
if filter_by_type is not None:
|
||||
if filter_by_type == "PRODUCT":
|
||||
@@ -213,15 +219,18 @@ def get_cost_assignments_by_type(cost_item, filter_by_type=None):
|
||||
if not filter_by_type or related_object.is_a(filter_by_type)
|
||||
]
|
||||
|
||||
|
||||
def get_cost_item_assignments(cost_item, filter_by_type=None, is_deep=False):
|
||||
if not is_deep:
|
||||
return get_cost_assignments_by_type(cost_item, filter_by_type)
|
||||
else:
|
||||
return [
|
||||
product for nested_cost_item in get_all_nested_cost_items(cost_item)
|
||||
product
|
||||
for nested_cost_item in get_all_nested_cost_items(cost_item)
|
||||
for product in get_cost_assignments_by_type(nested_cost_item, filter_by_type)
|
||||
]
|
||||
|
||||
|
||||
class CostValueUnserialiser:
|
||||
def parse(self, formula):
|
||||
l = lark.Lark(
|
||||
|
||||
Reference in New Issue
Block a user