mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Quality - run black on api/sequence directory
This commit is contained in:
@@ -39,13 +39,17 @@ class Usecase:
|
||||
):
|
||||
del self.settings["attributes"]["ScheduleFinish"]
|
||||
|
||||
duration_type = self.settings["attributes"].get("DurationType", self.settings["task_time"].DurationType)
|
||||
duration_type = self.settings["attributes"].get(
|
||||
"DurationType", self.settings["task_time"].DurationType
|
||||
)
|
||||
finish = self.settings["attributes"].get("ScheduleFinish", None)
|
||||
if finish:
|
||||
if isinstance(finish, str):
|
||||
finish = datetime.datetime.fromisoformat(finish)
|
||||
self.settings["attributes"]["ScheduleFinish"] = datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(finish, duration_type, self.calendar),
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
finish, duration_type, self.calendar
|
||||
),
|
||||
datetime.time(17),
|
||||
)
|
||||
start = self.settings["attributes"].get("ScheduleStart", None)
|
||||
@@ -53,7 +57,9 @@ class Usecase:
|
||||
if isinstance(start, str):
|
||||
start = datetime.datetime.fromisoformat(start)
|
||||
self.settings["attributes"]["ScheduleStart"] = datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(start, duration_type, self.calendar),
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
start, duration_type, self.calendar
|
||||
),
|
||||
datetime.time(9),
|
||||
)
|
||||
|
||||
@@ -61,7 +67,11 @@ class Usecase:
|
||||
if value is not None:
|
||||
if "Start" in name or "Finish" in name or name == "StatusTime":
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDateTime")
|
||||
elif name == "ScheduleDuration" or name == "ActualDuration" or name == "RemainingTime":
|
||||
elif (
|
||||
name == "ScheduleDuration"
|
||||
or name == "ActualDuration"
|
||||
or name == "RemainingTime"
|
||||
):
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
|
||||
setattr(self.settings["task_time"], name, value)
|
||||
|
||||
@@ -71,9 +81,15 @@ class Usecase:
|
||||
and self.settings["task_time"].ScheduleStart
|
||||
):
|
||||
self.calculate_finish()
|
||||
elif self.settings["attributes"].get("ScheduleStart", None) and self.settings["task_time"].ScheduleDuration:
|
||||
elif (
|
||||
self.settings["attributes"].get("ScheduleStart", None)
|
||||
and self.settings["task_time"].ScheduleDuration
|
||||
):
|
||||
self.calculate_finish()
|
||||
elif self.settings["attributes"].get("ScheduleFinish", None) and self.settings["task_time"].ScheduleStart:
|
||||
elif (
|
||||
self.settings["attributes"].get("ScheduleFinish", None)
|
||||
and self.settings["task_time"].ScheduleStart
|
||||
):
|
||||
self.calculate_duration()
|
||||
|
||||
if self.settings["task_time"].ScheduleDuration and (
|
||||
@@ -85,27 +101,48 @@ class Usecase:
|
||||
|
||||
def calculate_finish(self):
|
||||
finish = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleStart),
|
||||
ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleDuration),
|
||||
ifcopenshell.util.date.ifc2datetime(
|
||||
self.settings["task_time"].ScheduleStart
|
||||
),
|
||||
ifcopenshell.util.date.ifc2datetime(
|
||||
self.settings["task_time"].ScheduleDuration
|
||||
),
|
||||
self.settings["task_time"].DurationType,
|
||||
self.calendar,
|
||||
date_type="FINISH",
|
||||
)
|
||||
self.settings["task_time"].ScheduleFinish = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
||||
self.settings["task_time"].ScheduleFinish = ifcopenshell.util.date.datetime2ifc(
|
||||
finish, "IfcDateTime"
|
||||
)
|
||||
|
||||
def calculate_duration(self):
|
||||
start = ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleStart)
|
||||
finish = ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleFinish)
|
||||
start = ifcopenshell.util.date.ifc2datetime(
|
||||
self.settings["task_time"].ScheduleStart
|
||||
)
|
||||
finish = ifcopenshell.util.date.ifc2datetime(
|
||||
self.settings["task_time"].ScheduleFinish
|
||||
)
|
||||
current_date = datetime.date(start.year, start.month, start.day)
|
||||
finish_date = datetime.date(finish.year, finish.month, finish.day)
|
||||
duration = datetime.timedelta(days=1)
|
||||
while current_date < finish_date:
|
||||
if self.settings["task_time"].DurationType == "ELAPSEDTIME" or not self.calendar:
|
||||
if (
|
||||
self.settings["task_time"].DurationType == "ELAPSEDTIME"
|
||||
or not self.calendar
|
||||
):
|
||||
duration += datetime.timedelta(days=1)
|
||||
elif ifcopenshell.util.sequence.is_working_day(current_date, self.calendar):
|
||||
duration += datetime.timedelta(days=1)
|
||||
current_date += datetime.timedelta(days=1)
|
||||
self.settings["task_time"].ScheduleDuration = ifcopenshell.util.date.datetime2ifc(duration, "IfcDuration")
|
||||
self.settings[
|
||||
"task_time"
|
||||
].ScheduleDuration = ifcopenshell.util.date.datetime2ifc(
|
||||
duration, "IfcDuration"
|
||||
)
|
||||
|
||||
def get_task(self):
|
||||
return [e for e in self.file.get_inverse(self.settings["task_time"]) if e.is_a("IfcTask")][0]
|
||||
return [
|
||||
e
|
||||
for e in self.file.get_inverse(self.settings["task_time"])
|
||||
if e.is_a("IfcTask")
|
||||
][0]
|
||||
|
||||
Reference in New Issue
Block a user