'Convert string like "10.3 G" to bytes (binary units assumed). Return: float bytes.'

@staticmethod
def convert_to_bytes(string):

    units = dict(b=1, k=1024, m=(1024 ** 2), g=(1024 ** 3), t=(1024 ** 4), p=(1024 ** 5))
    string = (string or '')
    match = re.match('(\\d+(?:\\.\\d+)?)\\s*(\\w)?', string)
    if (not match):
        raise ValueError(('Cannot    convert    to    a    byte    size:    ' + string))
    (number, unit) = match.groups()
    multiplier = (1 if (not unit) else units.get(unit.lower()))
    if (not multiplier):
        raise ValueError(('Cannot    convert    to    a    byte    size:    ' + string))
    return (float(number) * multiplier)
