From 846ff3b9fd5709db1c9e2fa2d475a98af9ec0de0 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 9 Apr 2024 16:44:26 +0500 Subject: [PATCH] black format --- .../ifcopenshell/api/cost/copy_cost_item.py | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py index 55c4660b9f..f1cfdfa547 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py @@ -23,36 +23,36 @@ import ifcopenshell.util.element class Usecase: def __init__(self, file, cost_item=None): """Copies all cost items and related relationships - + The following relationships are also duplicated: - + * The copy will have the same attributes and property sets as the original cost item * The copy will be assigned to the parent cost schedule * The copy will have duplicated nested cost items - + :param cost_item: The cost item to be duplicated :type cost_item: ifcopenshell.entity_instance.entity_instance :return: The duplicated cost item or the list of duplicated cost items if the latter has children :rtype: ifcopenshell.entity_instance.entity_instance or list of ifcopenshell.entity_instance.entity_instance - + Example: .. code:: python - + # We have a cost item cost_item = CostItem(name="Design new feature", deadline="2023-03-01") - + # And now we have two - duplicated_cost_item = project.duplicate_cost_item(cost_item) - - + duplicated_cost_item = project.duplicate_cost_item(cost_item) + + """ self.file = file self.settings = {"cost_item": cost_item} - + def execute(self): self.new_cost_items = [] self.duplicate_cost_item(self.settings["cost_item"]) - + def duplicate_cost_item(self, cost_item): new_cost_item = ifcopenshell.util.element.copy_deep(self.file, cost_item) self.new_cost_items.append(new_cost_item) @@ -64,9 +64,7 @@ class Usecase: if inverse.is_a("IfcRelDefinesByProperties"): inverse = ifcopenshell.util.element.copy(self.file, inverse) inverse.RelatedObjects = [to_element] - pset = ifcopenshell.util.element.copy_deep( - self.file, inverse.RelatingPropertyDefinition - ) + pset = ifcopenshell.util.element.copy_deep(self.file, inverse.RelatingPropertyDefinition) inverse.RelatingPropertyDefinition = pset elif inverse.is_a("IfcRelNests") and inverse.RelatingObject == from_element: nested_cost_items = [e for e in inverse.RelatedObjects] @@ -79,9 +77,7 @@ class Usecase: inverse.RelatingObject = to_element inverse.RelatedObjects = new_cost_items for cost_item in new_cost_items: - ifcopenshell.api.run( - "nest.unassign_object", self.file, related_object=cost_item - ) + ifcopenshell.api.run("nest.unassign_object", self.file, related_object=cost_item) rel = ifcopenshell.api.run( "nest.assign_object", self.file,