From 3dfa8b827dff2d8079347a48fbbdbea102e9babc Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Fri, 23 Apr 2010 00:06:22 +0000 Subject: [PATCH] Fixed problem in getTargetType() when old_unit_type is None --- bin/weewx/units.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/weewx/units.py b/bin/weewx/units.py index 09434f0a..fb6f9995 100644 --- a/bin/weewx/units.py +++ b/bin/weewx/units.py @@ -510,6 +510,9 @@ class UnitInfo(object): Returns: the target unit type, such as 'mbar'. """ + # If there is no unit attached, then the target can only be None: + if not old_unit_type: + return None unit_group= unit_type_dict[old_unit_type] unit_type = self._getUnitTypeFromGroup(unit_group) return unit_type @@ -591,7 +594,7 @@ def convert(val_t, target_unit_type): the unit type (e.g., "foot", or "inHg") it is in. target_unit_type: The unit type (e.g., "meter", or "mbar") to - which the value is to be converted. + which the value is to be converted. If None, it will not be converted. returns: A value tuple converted into the desired units. """