Return a wrapper that runs given method only for valid URLs.

    :param func: a method to be wrapped
    :returns: a wrapper that adds argument validation

def accepts_valid_urls(func):
    """Return a wrapper that runs given method only for valid URLs.

    :param func: a method to be wrapped
    :returns: a wrapper that adds argument validation
    """
    @functools.wraps(func)
    def wrapper(obj, urls, *args, **kwargs):
        """Run the function and return a value for valid URLs.

        :param obj: an object in whose class f is defined
        :param urls: an iterable containing URLs
        :returns: a return value of the function f
        :raises InvalidURLError: if the iterable contains invalid URLs
        """
        invalid_urls = [u for u in urls if not is_valid_url(u)]
        if invalid_urls:
            msg_tpl = 'The values: {} are not valid URLs'
            msg = msg_tpl.format(','.join(invalid_urls))
            raise InvalidURLError(msg)
        return func(obj, urls, *args, **kwargs)
    return wrapper