def infer_unit(value):
 from apcaccess.status import ALL_UNITS
 for unit in ALL_UNITS:
  if value.endswith(unit):
   return (value[:(- len(unit))], INFERRED_UNITS.get(unit, unit.strip()))
 return (value, None)

def infer_unit ( value ) : from apcaccess . status import ALL_UNITS for unit in ALL_UNITS : if value . endswith ( unit ) : return ( value [ : ( - len ( unit ) ) ] , INFERRED_UNITS . get ( unit , unit . strip ( ) ) ) return ( value , None )
if the value ends with any of the units from all_units .