def str2size(s, scale=1024):
 if (not s):
  return 0
 if isinstance(s, six.integer_types):
  return s
 match = re.match('^([\\.\\d]+)\\s*([BbKkMmGgTtPpEeZzYy]?)', s)
 if (match is None):
  raise ValueError((_('Invalid value: "%s"') % s))
 groups = match.groups()
 value = float(groups[0])
 suffix = (((len(groups) > 1) and groups[1].upper()) or 'B')
 types = ('B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
 for (i, t) in enumerate(types):
  if (suffix == t):
   return int((value * pow(scale, i)))

def str2size ( s , scale = 1024 ) : if ( not s ) : return 0 if isinstance ( s , six . integer_types ) : return s match = re . match ( '^([\\.\\d]+)\\s*([BbKkMmGgTtPpEeZzYy]?)' , s ) if ( match is None ) : raise ValueError ( ( _ ( 'Invalid value: "%s"' ) % s ) ) groups = match . groups ( ) value = float ( groups [ 0 ] ) suffix = ( ( ( len ( groups ) > 1 ) and groups [ 1 ] . upper ( ) ) or 'B' ) types = ( 'B' , 'K' , 'M' , 'G' , 'T' , 'P' , 'E' , 'Z' , 'Y' ) for ( i , t ) in enumerate ( types ) : if ( suffix == t ) : return int ( ( value * pow ( scale , i ) ) )
convert size-string .