def parse_num(s):
 g = re.match('([-+\\d.e]+)\\s*(\\w*)', str(s))
 if (not g):
  raise ValueError(("can't parse %r as a number" % s))
 (val, unit) = g.groups()
 num = float(val)
 unit = unit.lower()
 if (unit in ['t', 'tb']):
  mult = (((1024 * 1024) * 1024) * 1024)
 elif (unit in ['g', 'gb']):
  mult = ((1024 * 1024) * 1024)
 elif (unit in ['m', 'mb']):
  mult = (1024 * 1024)
 elif (unit in ['k', 'kb']):
  mult = 1024
 elif (unit in ['', 'b']):
  mult = 1
 else:
  raise ValueError(('invalid unit %r in number %r' % (unit, s)))
 return int((num * mult))

def parse_num ( s ) : g = re . match ( '([-+\\d.e]+)\\s*(\\w*)' , str ( s ) ) if ( not g ) : raise ValueError ( ( "can't parse %r as a number" % s ) ) ( val , unit ) = g . groups ( ) num = float ( val ) unit = unit . lower ( ) if ( unit in [ 't' , 'tb' ] ) : mult = ( ( ( 1024 * 1024 ) * 1024 ) * 1024 ) elif ( unit in [ 'g' , 'gb' ] ) : mult = ( ( 1024 * 1024 ) * 1024 ) elif ( unit in [ 'm' , 'mb' ] ) : mult = ( 1024 * 1024 ) elif ( unit in [ 'k' , 'kb' ] ) : mult = 1024 elif ( unit in [ '' , 'b' ] ) : mult = 1 else : raise ValueError ( ( 'invalid unit %r in number %r' % ( unit , s ) ) ) return int ( ( num * mult ) )
returns a first index>=start of chat not in charset .