

def gen_url(scheme=None, subdomain=None, tlds=None):
    "Generates a random URL address\n\n    :param str scheme: Either http, https or ftp.\n    :param str subdomain: A valid subdmain\n    :param str tlds: A qualified top level domain name (e.g. 'com', 'net')\n    :raises: ``ValueError`` if arguments are not valid.\n    :returns: A random URL address.\n    :rtype: str\n\n    "
    subdomainator = re.compile('^[a-zA-Z0-9][-\\w.~]*$')
    schemenator = re.compile('^(https?|ftp)$')
    tldsnator = re.compile('^[a-zA-Z]{1,3}$')
    if scheme:
        if (schemenator.match(scheme) is None):
            raise ValueError('Protocol {0} is not valid.'.format(scheme))
    else:
        scheme = gen_choice(SCHEMES)
    if subdomain:
        if (subdomainator.match(subdomain) is None):
            raise ValueError('Subdomain {0} is invalid.'.format(tldsnator))
    else:
        subdomain = gen_choice(SUBDOMAINS)
    if tlds:
        if (tldsnator.match(tlds) is None):
            raise ValueError('TLDS name {0} is invalid.'.format(tlds))
    else:
        tlds = gen_choice(TLDS)
    url = '{0}://{1}.{2}'.format(scheme, subdomain, tlds)
    return _make_unicode(url)

dataset/ETHPy150Open omaciel/fauxfactory/fauxfactory/__init__.py gen_url/VarMisuse@119/335 `subdomain`->`tldsnator`