def parse_size(size_input):
 prefixes = [None, u'K', u'M', u'G', u'T', u'P']
 try:
  return int(size_input)
 except ValueError:
  size_input = size_input.upper().rstrip(u'IB')
  (value, unit) = (float(size_input[:(-1)]), size_input[(-1):])
  if (unit not in prefixes):
   raise ValueError(u"should be in format '0-x (KiB, MiB, GiB, TiB, PiB)'")
  return int(((1024 ** prefixes.index(unit)) * value))

def parse_size ( size_input ) : prefixes = [ None , u'K' , u'M' , u'G' , u'T' , u'P' ] try : return int ( size_input ) except ValueError : size_input = size_input . upper ( ) . rstrip ( u'IB' ) ( value , unit ) = ( float ( size_input [ : ( - 1 ) ] ) , size_input [ ( - 1 ) : ] ) if ( unit not in prefixes ) : raise ValueError ( u"should be in format '0-x (KiB, MiB, GiB, TiB, PiB)'" ) return int ( ( ( 1024 ** prefixes . index ( unit ) ) * value ) )
parses a size specification .