From 2c31fc6b2539e9a795e2c79ef707a4de61bd141f Mon Sep 17 00:00:00 2001 From: Sigma Dimensions <79010126+myoualid@users.noreply.github.com> Date: Tue, 2 May 2023 02:27:32 +0100 Subject: [PATCH] run black --- .../ifcopenshell/api/sequence/add_task.py | 10 +++++-- .../api/sequence/add_work_schedule.py | 9 +++++- .../api/sequence/assign_lag_time.py | 4 ++- .../api/sequence/assign_process.py | 1 - .../api/sequence/assign_sequence.py | 12 ++++++-- .../api/sequence/edit_recurrence_pattern.py | 5 +++- .../api/sequence/remove_work_schedule.py | 28 +++++++++++++++++-- 7 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py index 85b59c54c9..80244df3a5 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py @@ -165,7 +165,9 @@ class Usecase: "IfcRelAssignsToControl", **{ "GlobalId": ifcopenshell.guid.new(), - "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), + "OwnerHistory": ifcopenshell.api.run( + "owner.create_owner_history", self.file + ), "RelatedObjects": [task], "RelatingControl": self.settings["work_schedule"], } @@ -178,5 +180,9 @@ class Usecase: relating_object=self.settings["parent_task"], ) if self.settings["parent_task"].Identification: - task.Identification = self.settings["parent_task"].Identification + "." + str(len(rel.RelatedObjects)) + task.Identification = ( + self.settings["parent_task"].Identification + + "." + + str(len(rel.RelatedObjects)) + ) return task diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py index faae1a39b0..ec63d53b3d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py @@ -22,7 +22,14 @@ from datetime import datetime class Usecase: - def __init__(self, file, name="Unnamed", predefined_type="NOTDEFINED", start_time=None, work_plan=None): + def __init__( + self, + file, + name="Unnamed", + predefined_type="NOTDEFINED", + start_time=None, + work_plan=None, + ): """Add a new work schedule A work schedule is a group of tasks, where the tasks are typically diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py index b6ff16bbf2..97e644e05d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py @@ -20,7 +20,9 @@ import ifcopenshell.util.date class Usecase: - def __init__(self, file, rel_sequence=None, lag_value=None, duration_type="WORKTIME"): + def __init__( + self, file, rel_sequence=None, lag_value=None, duration_type="WORKTIME" + ): """Assign a lag time to a sequence relationship between tasks A task sequence (e.g. finish to start) may optionally have a lag time diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py index 9d703f65be..ea758b9182 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py @@ -93,7 +93,6 @@ class Usecase: "related_object": related_object, } - def execute(self): if self.settings["related_object"].HasAssignments: for assignment in self.settings["related_object"].HasAssignments: diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py index 37be7d83af..a3b4dd2a16 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py @@ -21,7 +21,13 @@ import ifcopenshell.api class Usecase: - def __init__(self, file, relating_process=None, related_process=None, sequence_type="FINISH_START"): + def __init__( + self, + file, + relating_process=None, + related_process=None, + sequence_type="FINISH_START", + ): """Assign a sequential relationship between tasks Tasks in construction sequencing typically have sequence relationships @@ -118,7 +124,9 @@ class Usecase: "IfcRelSequence", **{ "GlobalId": ifcopenshell.guid.new(), - "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), + "OwnerHistory": ifcopenshell.api.run( + "owner.create_owner_history", self.file + ), "RelatingProcess": self.settings["relating_process"], "RelatedProcess": self.settings["related_process"], "SequenceType": self.settings["sequence_type"], diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py index 75198ff6c6..f5eb567f6d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py @@ -54,7 +54,10 @@ class Usecase: recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]}) """ self.file = file - self.settings = {"recurrence_pattern": recurrence_pattern, "attributes": attributes or {}} + self.settings = { + "recurrence_pattern": recurrence_pattern, + "attributes": attributes or {}, + } def execute(self): for name, value in self.settings["attributes"].items(): diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py index ee78e99f69..aee6b94f1c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py @@ -55,10 +55,32 @@ class Usecase: definition=self.settings["work_schedule"], relating_context=self.file.by_type("IfcContext")[0], ) - for rel in self.settings["work_schedule"].Controls: - for related_object in rel.RelatedObjects: - if related_object.is_a("IfcTask"): + if self.settings["work_schedule"].Declares: + for rel in self.settings["work_schedule"].Declares: + for work_schedule in rel.RelatedObjects: + ifcopenshell.api.run( + "sequence.remove_work_schedule", + self.file, + work_schedule=work_schedule, + ) + for inverse in self.file.get_inverse(self.settings["work_schedule"]): + if inverse.is_a("IfcRelDefinesByObject"): + if ( + inverse.RelatingObject == self.settings["work_schedule"] + or len(inverse.RelatedObjects) == 1 + ): + self.file.remove(inverse) + else: + related_objects = list(inverse.RelatedObjects) + related_objects.remove(self.settings["work_schedule"]) + inverse.RelatedObjects = related_objects + elif inverse.is_a("IfcRelAssignsToControl"): + [ ifcopenshell.api.run( "sequence.remove_task", self.file, task=related_object ) + for related_object in inverse.RelatedObjects + if related_object.is_a("IfcTask") + ] + self.file.remove(self.settings["work_schedule"])