def GetBytes(mem_str):
 unit = mem_str[(-1)]
 val = float(mem_str[:(-1)])
 if (unit == 'G'):
  val *= ((1024 * 1024) * 1024)
 elif (unit == 'M'):
  val *= (1024 * 1024)
 elif (unit == 'K'):
  val *= 1024
 else:
  try:
   val = int(mem_str)
  except Exception:
   print ('%s is not a valid way of writing memory size.' % mem_str)
 return int(val)

def GetBytes ( mem_str ) : unit = mem_str [ ( - 1 ) ] val = float ( mem_str [ : ( - 1 ) ] ) if ( unit == 'G' ) : val *= ( ( 1024 * 1024 ) * 1024 ) elif ( unit == 'M' ) : val *= ( 1024 * 1024 ) elif ( unit == 'K' ) : val *= 1024 else : try : val = int ( mem_str ) except Exception : print ( '%s is not a valid way of writing memory size.' % mem_str ) return int ( val )
converts human-readable numbers to bytes .