def si_as_number(text):
    """Convert a string containing an SI value to an integer or return an
    integer if that is what was passed in."""

    if type(text) == int:
        return text

    if type(text) not in [str, unicode]:
        raise ValueError("Source value must be string or integer")

    matches = si_regex.search(text.lower(), 0)

    if matches is None:
        raise ValueError("Invalid SI value '" + text + "'")

    number = int(matches.group(1)) if matches.group(2) is None \
        else float(matches.group(1))

    unit = matches.group(3)

    multiplier = 1 if unit is None else si_multipliers.get(unit.lower(), '')

    return number * multiplier