mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
run black
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user