diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py index 10c9ad27fa..c353888656 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py +++ b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py @@ -56,10 +56,6 @@ def add_resource_time(file: ifcopenshell.file, resource: ifcopenshell.entity_ins ifcopenshell.api.run("resource.edit_resource_time", model, resource_time=time, attributes={"ScheduleWork": "PT16H"}) """ - settings = { - "resource": resource, - } - resource_time = file.create_entity("IfcResourceTime") - settings["resource"].Usage = resource_time + resource.Usage = resource_time return resource_time 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 3bb6fe4cd4..29b80283c0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py +++ b/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py @@ -56,17 +56,15 @@ def calculate_resource_work(file: ifcopenshell.file, resource: ifcopenshell.enti :return None: :rtype: None: """ - settings = {"resource": resource} - - if ifcopenshell.util.constraint.is_attribute_locked(settings["resource"], "Usage.ScheduleWork"): + if ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleWork"): return - amount_worked = ifcopenshell.util.resource.get_resource_required_work(settings["resource"]) + amount_worked = ifcopenshell.util.resource.get_resource_required_work(resource) if not amount_worked: return - if not settings["resource"].Usage: + if not resource.Usage: ifcopenshell.api.run( "resource.add_resource_time", file, - resource=settings["resource"], + resource=resource, ) - settings["resource"].Usage.ScheduleWork = amount_worked + resource.Usage.ScheduleWork = amount_worked diff --git a/src/ifcopenshell-python/ifcopenshell/util/date.py b/src/ifcopenshell-python/ifcopenshell/util/date.py index 3ddee3e18f..ce2c72289a 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/date.py +++ b/src/ifcopenshell-python/ifcopenshell/util/date.py @@ -22,8 +22,8 @@ from dateutil import parser try: import isodate -except: - pass # Duration parsing not supported +except ModuleNotFoundError as e: + print(f"Note: duration parsing not available due to missing dependencies: util.date - {e}") def timedelta2duration(timedelta): @@ -187,8 +187,6 @@ def parse_duration(value): if "P" in value: try: return isodate.parse_duration(value) - except ModuleNotFoundError: - print("Duration parsing not supported: isodate module not found") except: print("Error parsing ISO string duration") return None