def from_units(val):
 val = str(val).strip().upper()
 if (val == '-1'):
  return val
 m = RE_UNITS.search(val)
 if m:
  if m.group(2):
   val = float(m.group(1))
   unit = m.group(2)
   n = 0
   while (unit != TAB_UNITS[n]):
    val = (val * 1024.0)
    n = (n + 1)
  else:
   val = m.group(1)
  try:
   return float(val)
  except:
   return 0.0
 else:
  return 0.0

def from_units ( val ) : val = str ( val ) . strip ( ) . upper ( ) if ( val == '-1' ) : return val m = RE_UNITS . search ( val ) if m : if m . group ( 2 ) : val = float ( m . group ( 1 ) ) unit = m . group ( 2 ) n = 0 while ( unit != TAB_UNITS [ n ] ) : val = ( val * 1024.0 ) n = ( n + 1 ) else : val = m . group ( 1 ) try : return float ( val ) except : return 0.0 else : return 0.0
convert k/m/g/t/p notation to float .