import re


def _parse_human_filesize(m):
    """Parses human readable file sizes, such as "1240", "200k", "30m", and
    returns them as int. Raises ValueError if the value cannot be parsed."""
    try:
        return int(m)
    except ValueError as e:
        match = re.match("^(\\d+)([kmgtp])$", m)
        if match:
            digits = match[1]
            suffix = match[2]
            multiplier = 1
            for letter in ["k", "m", "g", "t", "p"]:
                multiplier *= 1024
                if suffix == letter:
                    return multiplier * int(digits)

        raise e