def memstr_to_bytes(text):
 kilo = 1024
 units = dict(K=kilo, M=(kilo ** 2), G=(kilo ** 3))
 try:
  size = int((units[text[(-1)]] * float(text[:(-1)])))
 except (KeyError, ValueError):
  raise ValueError(("Invalid literal for size give: %s (type %s) should be alike '10G', '500M', '50K'." % (text, type(text))))
 return size

def memstr_to_bytes ( text ) : kilo = 1024 units = dict ( K = kilo , M = ( kilo ** 2 ) , G = ( kilo ** 3 ) ) try : size = int ( ( units [ text [ ( - 1 ) ] ] * float ( text [ : ( - 1 ) ] ) ) ) except ( KeyError , ValueError ) : raise ValueError ( ( "Invalid literal for size give: %s (type %s) should be alike '10G', '500M', '50K'." % ( text , type ( text ) ) ) ) return size
convert a memory text to its value in bytes .