rework unpack_unit_value

handle the `None` case, simplify logic
This commit is contained in:
Totally a booplicate
2023-06-04 14:56:43 +03:00
committed by Thomas Krijnen
parent 3d787338fb
commit 51e5f843ba
@@ -405,10 +405,14 @@ class Usecase:
@staticmethod
def unpack_unit_value(value_candidate):
unit = None
"""
Returns tuple of the format: (Unit, NominalValue)
NOTE: Unit fallbacks to None
"""
if value_candidate is None:
return (None, None)
if isinstance(value_candidate, dict): # Custom IfcUnits can be passed in a dict along with the pset value
unit = value_candidate["Unit"]
value = value_candidate["NominalValue"]
else:
value = value_candidate
return unit, value
return (value_candidate["Unit"], value_candidate["NominalValue"])
return (None, value_candidate)