Return a size from a list of sizes.

def size_from_name(size, sizes):

    """Return a size from a list of sizes."""

    by_name = [s for s in sizes if s.name == size]
    if len(by_name) > 1:
        raise Exception('more than one image named %s exists' % size)
    return by_name[0]