import re


def walltime_seconds(walltime):
    """Given a walltime string, return the number of seconds it represents.

    Args:
        walltime (str): Walltime, eg. '01:00:00'.

    Returns:
        int: Number of seconds represented by the walltime.

    Raises:
        ValueError: If an unsupported walltime format is supplied.

    """
    match = re.fullmatch(r"(\d{1,3}):(\d{1,2}):(\d{1,2})", walltime)
    if match is None:
        raise ValueError(
            f"Expected walltime like '02:30:40', but got {repr(walltime)}."
        )
    hours, minutes, seconds = match.groups()
    return int(hours) * 60 * 60 + int(minutes) * 60 + int(seconds)