mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 08:56:34 +00:00
per review
change exception message remove TODO pass `Unit` raise `NotImplementedError` when no template was found
This commit is contained in:
committed by
Thomas Krijnen
parent
d4b88fd422
commit
375f4f2a86
@@ -243,10 +243,12 @@ class Usecase:
|
|||||||
if value is None:
|
if value is None:
|
||||||
continue
|
continue
|
||||||
unit, value = self.unpack_unit_value(value)
|
unit, value = self.unpack_unit_value(value)
|
||||||
|
|
||||||
if isinstance(value, ifcopenshell.entity_instance):
|
if isinstance(value, ifcopenshell.entity_instance):
|
||||||
if value.is_a("IfcProperty"):
|
if value.is_a("IfcProperty"):
|
||||||
properties.append(value)
|
properties.append(value)
|
||||||
|
|
||||||
|
# If it's not an entity, then it's a primitive data type
|
||||||
elif not value.is_entity():
|
elif not value.is_entity():
|
||||||
args = {"Name": name, "NominalValue": value}
|
args = {"Name": name, "NominalValue": value}
|
||||||
if unit:
|
if unit:
|
||||||
@@ -256,9 +258,8 @@ class Usecase:
|
|||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"'{value}' is not a valid property value for '{name}'")
|
raise ValueError(f"{value.is_a()} cannot be assigned to the property set '{name}'")
|
||||||
|
|
||||||
# TODO-The following "elif" is temporary code, will need to refactor at some point - vulevukusej
|
|
||||||
elif isinstance(value, (tuple, list)):
|
elif isinstance(value, (tuple, list)):
|
||||||
if not value:
|
if not value:
|
||||||
continue
|
continue
|
||||||
@@ -278,7 +279,8 @@ class Usecase:
|
|||||||
ListValues=[
|
ListValues=[
|
||||||
self.file.create_entity(ifc_class, v)
|
self.file.create_entity(ifc_class, v)
|
||||||
for v in value
|
for v in value
|
||||||
]
|
],
|
||||||
|
Unit=unit
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
@@ -303,7 +305,7 @@ class Usecase:
|
|||||||
|
|
||||||
raise NotImplementedError(f"Template type '{pset_template.TemplateType}' is not supported yet")
|
raise NotImplementedError(f"Template type '{pset_template.TemplateType}' is not supported yet")
|
||||||
|
|
||||||
# TODO: what if no template was found/matched?
|
raise NotImplementedError(f"No template found for property '{name}'")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
primary_measure_type = self.get_primary_measure_type(name, new_value=value)
|
primary_measure_type = self.get_primary_measure_type(name, new_value=value)
|
||||||
|
|||||||
Reference in New Issue
Block a user