mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +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
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user