mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
rework unpack_unit_value
handle the `None` case, simplify logic
This commit is contained in:
committed by
Thomas Krijnen
parent
3d787338fb
commit
51e5f843ba
@@ -405,10 +405,14 @@ class Usecase:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def unpack_unit_value(value_candidate):
|
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
|
if isinstance(value_candidate, dict): # Custom IfcUnits can be passed in a dict along with the pset value
|
||||||
unit = value_candidate["Unit"]
|
return (value_candidate["Unit"], value_candidate["NominalValue"])
|
||||||
value = value_candidate["NominalValue"]
|
|
||||||
else:
|
return (None, value_candidate)
|
||||||
value = value_candidate
|
|
||||||
return unit, value
|
|
||||||
|
|||||||
Reference in New Issue
Block a user