def human_size_to_bytes(human_size):
 size_exp_map = {'K': 1, 'M': 2, 'G': 3, 'T': 4, 'P': 5}
 human_size_str = str(human_size)
 match = re.match('^(\\d+)([KMGTP])?$', human_size_str)
 if (not match):
  raise ValueError('Size must be all digits, with an optional unit type (K, M, G, T, or P)')
 size_num = int(match.group(1))
 unit_multiplier = (1024 ** size_exp_map.get(match.group(2), 0))
 return (size_num * unit_multiplier)

def human_size_to_bytes ( human_size ) : size_exp_map = { 'K' : 1 , 'M' : 2 , 'G' : 3 , 'T' : 4 , 'P' : 5 } human_size_str = str ( human_size ) match = re . match ( '^(\\d+)([KMGTP])?$' , human_size_str ) if ( not match ) : raise ValueError ( 'Size must be all digits, with an optional unit type (K, M, G, T, or P)' ) size_num = int ( match . group ( 1 ) ) unit_multiplier = ( 1024 ** size_exp_map . get ( match . group ( 2 ) , 0 ) ) return ( size_num * unit_multiplier )
convert human-readable units to bytes .