mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 04:04:00 +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)
|
map_element_to_result(cost_value, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_cost_items_for_product(product):
|
def get_cost_items_for_product(product):
|
||||||
"""
|
"""
|
||||||
Returns a list of cost items related to the given 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)
|
cost_items.append(assignment.RelatingControl)
|
||||||
return cost_items
|
return cost_items
|
||||||
|
|
||||||
|
|
||||||
def get_root_cost_items(cost_schedule):
|
def get_root_cost_items(cost_schedule):
|
||||||
return [
|
return [
|
||||||
related_object
|
related_object
|
||||||
@@ -182,22 +184,26 @@ def get_root_cost_items(cost_schedule):
|
|||||||
if related_object.is_a("IfcCostItem")
|
if related_object.is_a("IfcCostItem")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_all_nested_cost_items(cost_item):
|
def get_all_nested_cost_items(cost_item):
|
||||||
for cost_item in get_nested_cost_items(cost_item):
|
for cost_item in get_nested_cost_items(cost_item):
|
||||||
yield cost_item
|
yield cost_item
|
||||||
yield from get_all_nested_cost_items(cost_item)
|
yield from get_all_nested_cost_items(cost_item)
|
||||||
|
|
||||||
|
|
||||||
def get_nested_cost_items(cost_item, is_deep=False):
|
def get_nested_cost_items(cost_item, is_deep=False):
|
||||||
if is_deep:
|
if is_deep:
|
||||||
return list(get_all_nested_cost_items(cost_item))
|
return list(get_all_nested_cost_items(cost_item))
|
||||||
else:
|
else:
|
||||||
return [obj for rel in cost_item.IsNestedBy for obj in rel.RelatedObjects]
|
return [obj for rel in cost_item.IsNestedBy for obj in rel.RelatedObjects]
|
||||||
|
|
||||||
|
|
||||||
def get_schedule_cost_items(cost_schedule):
|
def get_schedule_cost_items(cost_schedule):
|
||||||
for cost_item in get_root_cost_items(cost_schedule):
|
for cost_item in get_root_cost_items(cost_schedule):
|
||||||
yield cost_item
|
yield cost_item
|
||||||
yield from get_all_nested_cost_items(cost_item)
|
yield from get_all_nested_cost_items(cost_item)
|
||||||
|
|
||||||
|
|
||||||
def get_cost_assignments_by_type(cost_item, filter_by_type=None):
|
def get_cost_assignments_by_type(cost_item, filter_by_type=None):
|
||||||
if filter_by_type is not None:
|
if filter_by_type is not None:
|
||||||
if filter_by_type == "PRODUCT":
|
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)
|
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):
|
def get_cost_item_assignments(cost_item, filter_by_type=None, is_deep=False):
|
||||||
if not is_deep:
|
if not is_deep:
|
||||||
return get_cost_assignments_by_type(cost_item, filter_by_type)
|
return get_cost_assignments_by_type(cost_item, filter_by_type)
|
||||||
else:
|
else:
|
||||||
return [
|
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)
|
for product in get_cost_assignments_by_type(nested_cost_item, filter_by_type)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class CostValueUnserialiser:
|
class CostValueUnserialiser:
|
||||||
def parse(self, formula):
|
def parse(self, formula):
|
||||||
l = lark.Lark(
|
l = lark.Lark(
|
||||||
|
|||||||
Reference in New Issue
Block a user