def convert_data_size(size, default_sufix='B'):
 orders = {'B': 1, 'K': 1024, 'M': (1024 * 1024), 'G': ((1024 * 1024) * 1024), 'T': (((1024 * 1024) * 1024) * 1024)}
 order = re.findall('([BbKkMmGgTt])', size[(-1)])
 if (not order):
  size += default_sufix
  order = [default_sufix]
 return int((float(size[0:(-1)]) * orders[order[0].upper()]))

def convert_data_size ( size , default_sufix = 'B' ) : orders = { 'B' : 1 , 'K' : 1024 , 'M' : ( 1024 * 1024 ) , 'G' : ( ( 1024 * 1024 ) * 1024 ) , 'T' : ( ( ( 1024 * 1024 ) * 1024 ) * 1024 ) } order = re . findall ( '([BbKkMmGgTt])' , size [ ( - 1 ) ] ) if ( not order ) : size += default_sufix order = [ default_sufix ] return int ( ( float ( size [ 0 : ( - 1 ) ] ) * orders [ order [ 0 ] . upper ( ) ] ) )
convert data size from human readable units to an int of arbitrary size .