def metric_prefix(s):
    # type: (str) -> int
    """Parse a metric prefix as a number."""
    s_old = s
    s = s.strip().lower()
    if s == "":
        return 1
    if s == "k":
        return 1000
    if s == "m":
        return 1000 ** 2
    if s == "g":
        return 1000 ** 3
    if s == "t":
        return 1000 ** 4
    raise ValueError("unknown metric prefix: {0}".format(s_old))