run black

This commit is contained in:
Sigma Dimensions (Yass)
2023-08-23 21:21:19 +01:00
parent 1996e98506
commit ed58072d64
2 changed files with 24 additions and 10 deletions
@@ -60,8 +60,14 @@ class Usecase:
self.settings = {"resource": resource} self.settings = {"resource": resource}
def execute(self): def execute(self):
metrics= ifcopenshell.util.constraint.has_metric_constraints(self.settings["resource"], "Usage.ScheduleWork") metrics = ifcopenshell.util.constraint.has_metric_constraints(
if metrics and metrics[0].ConstraintGrade == "HARD" and metrics[0].Benchmark == "EQUALTO": self.settings["resource"], "Usage.ScheduleWork"
)
if (
metrics
and metrics[0].ConstraintGrade == "HARD"
and metrics[0].Benchmark == "EQUALTO"
):
return return
amount_worked = ifcopenshell.util.resource.get_resource_required_work( amount_worked = ifcopenshell.util.resource.get_resource_required_work(
self.settings["resource"] self.settings["resource"]
@@ -19,6 +19,7 @@
import datetime import datetime
import ifcopenshell import ifcopenshell
class Usecase: class Usecase:
def __init__(self, file, resource_time=None, attributes=None): def __init__(self, file, resource_time=None, attributes=None):
"""Edits the attributes of an IfcResourceTime """Edits the attributes of an IfcResourceTime
@@ -76,8 +77,10 @@ class Usecase:
del self.settings["attributes"]["ActualFinish"] del self.settings["attributes"]["ActualFinish"]
for name, value in self.settings["attributes"].items(): for name, value in self.settings["attributes"].items():
metrics = ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage." + name) metrics = ifcopenshell.util.constraint.has_metric_constraints(
if metrics and self.is_hard_constraint(metrics[0]): self.resource, "Usage." + name
)
if metrics and self.is_hard_constraint(metrics[0]):
continue continue
if value: if value:
if "Start" in name or "Finish" in name or name == "StatusTime": if "Start" in name or "Finish" in name or name == "StatusTime":
@@ -89,12 +92,17 @@ class Usecase:
): ):
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration") value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
setattr(self.settings["resource_time"], name, value) setattr(self.settings["resource_time"], name, value)
if name == "ScheduleUsage" and ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage.ScheduleWork"): if (
for rel in self.resource.HasAssignments or []: name == "ScheduleUsage"
if not rel.is_a("IfcRelAssignsToProcess"): and ifcopenshell.util.constraint.has_metric_constraints(
continue self.resource, "Usage.ScheduleWork"
task = rel.RelatingProcess )
ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task) ):
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): def is_hard_constraint(self, metric):
return bool(metric.ConstraintGrade == "HARD" and metric.Benchmark == "EQUALTO") return bool(metric.ConstraintGrade == "HARD" and metric.Benchmark == "EQUALTO")