From 002985a44672fbbe472d44549ed49f7f9777c347 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Wed, 23 Aug 2023 21:21:19 +0100 Subject: [PATCH] run black --- .../api/resource/calculate_resource_work.py | 10 ++++++-- .../api/resource/edit_resource_time.py | 24 ++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py b/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py index cc6717fd5f..c8638e846c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py +++ b/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py @@ -60,8 +60,14 @@ class Usecase: self.settings = {"resource": resource} def execute(self): - metrics= ifcopenshell.util.constraint.has_metric_constraints(self.settings["resource"], "Usage.ScheduleWork") - if metrics and metrics[0].ConstraintGrade == "HARD" and metrics[0].Benchmark == "EQUALTO": + metrics = ifcopenshell.util.constraint.has_metric_constraints( + self.settings["resource"], "Usage.ScheduleWork" + ) + if ( + metrics + and metrics[0].ConstraintGrade == "HARD" + and metrics[0].Benchmark == "EQUALTO" + ): return amount_worked = ifcopenshell.util.resource.get_resource_required_work( self.settings["resource"] diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py index 29317007fb..22d800a5c6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py +++ b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py @@ -19,6 +19,7 @@ import datetime import ifcopenshell + class Usecase: def __init__(self, file, resource_time=None, attributes=None): """Edits the attributes of an IfcResourceTime @@ -76,8 +77,10 @@ class Usecase: del self.settings["attributes"]["ActualFinish"] for name, value in self.settings["attributes"].items(): - metrics = ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage." + name) - if metrics and self.is_hard_constraint(metrics[0]): + metrics = ifcopenshell.util.constraint.has_metric_constraints( + self.resource, "Usage." + name + ) + if metrics and self.is_hard_constraint(metrics[0]): continue if value: if "Start" in name or "Finish" in name or name == "StatusTime": @@ -89,12 +92,17 @@ class Usecase: ): value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration") setattr(self.settings["resource_time"], name, value) - if name == "ScheduleUsage" and ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage.ScheduleWork"): - for rel in self.resource.HasAssignments or []: - if not rel.is_a("IfcRelAssignsToProcess"): - continue - task = rel.RelatingProcess - ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task) + if ( + name == "ScheduleUsage" + and ifcopenshell.util.constraint.has_metric_constraints( + self.resource, "Usage.ScheduleWork" + ) + ): + task = ifcopenshell.util.resource.get_task_assignments(self.resource) + if task: + ifcopenshell.api.run( + "sequence.calculate_task_duration", self.file, task=task + ) def is_hard_constraint(self, metric): return bool(metric.ConstraintGrade == "HARD" and metric.Benchmark == "EQUALTO")