def parse_filesize(filesize):
    """ Parse a human readable filesize string into a integer.
    Only the suffixes 'k' and 'M' are supported. """
    try:
        if filesize.endswith('k'):
            return int(filesize[:-1]) * 1024
        if filesize.endswith('M'):
            return int(filesize[:-1]) * 1048576
        return int(filesize)
    except ValueError as error:
        # include the original exception
        raise ValueError('Invalid size: {}'.format(filesize)) from error