Normalizes a hostname so that it is ASCII and valid domain name.
965036
def normalize_hostname(hostname):
    ''''''
    try:
        new_hostname = hostname.encode('idna').decode('ascii').lower()
    except UnicodeError as error:
        raise UnicodeError('Hostname {} rejected: {}'.format(hostname, error)) from error

    if hostname != new_hostname:
        # Check for round-trip. May raise UnicodeError
        new_hostname.encode('idna')

    return new_hostname
240753
def normalize_codec_name(name):
    '''
    '''
    name = UnicodeDammit.CHARSET_ALIASES.get(name.lower(), name)

    try:
        return codecs.lookup(name).name
    except (LookupError, TypeError, ValueError):
        # TypeError occurs when name contains \x00 (ValueError in Py3.5)
        pass
227324
def normalize_pipeline_name(name=''):
    """"""
    normalized_name = name
    for bad in '\\/?%#':
        normalized_name = normalized_name.replace(bad, '_')
    return normalized_name
185078
def normalize_name(s):
    
    # Normalize the string into a byte string form
    s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
    # Remove the byte string and quotes from the string
    s = str(s)[2:-1]
    return s
1137845
def lookup(sock, domain, cache = None):
    """"""
    domain = normalize_domain(domain)

    # cache miss, perform lookup
    reply = sam_cmd(sock, "NAMING LOOKUP NAME=%s" % domain)

    b64_dest = reply.get('VALUE')
    if b64_dest:
        dest = Dest(b64_dest, encoding='base64')
        if cache:
            cache[dest.base32 + '.b32.i2p'] = dest
        return dest
    else:
        raise NSError('Domain name %r not resolved because %r' % (domain, reply))
1281249
def is_valid_hostname(hostname):
    ''''''
    if not isinstance(hostname, str):
        raise TypeError('hostname must be a string')
    # strip exactly one dot from the right, if present
    if hostname and hostname[-1] == ".":
        hostname = hostname[:-1]
    if not hostname or len(hostname) > 253:
        return False
    labels = hostname.split('.')
    # the TLD must be not all-numeric
    if re.match(NUMERIC_REGEX, labels[-1]):
        return False
    return all(LABEL_REGEX.match(label) for label in labels)
889334
public static function hostname($domain, bool $www=false, bool $unicode=false) {
		ref\sanitize::hostname($domain, $www, $unicode);
		return $domain;
	}
665456
def normalize_table_name(name):
    """"""
    if not isinstance(name, six.string_types):
        raise ValueError("Invalid table name: %r" % name)
    name = name.strip()[:63]
    if not len(name):
        raise ValueError("Invalid table name: %r" % name)
    return name
430949
def normalize_host(host):
    """"""
    if 'xn--' not in host:
        return host
    return '.'.join([_idna_decode(p) for p in host.split('.')])
1170896
public static function toAscii($string)
    {
        $string = explode('@', $string);

        // Not addressing UTF-8 user names
        $new = $string[0];

        if (!empty($string[1])) {
            $domainExploded = explode('.', $string[1]);
            $newdomain      = '';

            foreach ($domainExploded as $domainex) {
                $domainex  = static::encode($domainex);
                $newdomain .= $domainex . '.';
            }

            $newdomain = substr($newdomain, 0, -1);
            $new       = $new . '@' . $newdomain;
        }

        return $new;
    }
1112297
def normalizeToName(val):
    
    if val not in tagsAndNameSet:
        raise KeyError("{} is not a tag or name string".format(val))
    else:
        try:
            return tagToFullDict[val]
        except KeyError:
            return val
881537
static String normalizeDefaultHostname(String defaultHostname) {
        requireNonNull(defaultHostname, "defaultHostname");
        if (needsNormalization(defaultHostname)) {
            defaultHostname = IDN.toASCII(defaultHostname, IDN.ALLOW_UNASSIGNED);
        }

        if (!HOSTNAME_PATTERN.matcher(defaultHostname).matches()) {
            throw new IllegalArgumentException("defaultHostname: " + defaultHostname);
        }

        return Ascii.toLowerCase(defaultHostname);
    }
275306
def normalize_name(name):
    
    name = name.casefold()
    name = name.replace("’", "'")
    name = name.replace("-", " ")
    name = name.replace("(", "")
    name = name.replace(")", "")
    name = name.replace(",", "")
    return name.strip()
524661
def addressable_normalize(url)
      addressable_uri = Addressable::URI.parse(url)
      addressable_uri.normalize.to_s
    end
99539
def valid_hostnames(hostname_list):
    
    for entry in hostname_list:
        if len(entry) > 255:
            return False
        allowed = re.compile('(?!-)[A-Z\d-]{1,63}(?<!-)$', re.IGNORECASE)
        if not all(allowed.match(x) for x in entry.split(".")):
            return False
    return True
38100
def parse_ipv6_hostname(cls, hostname):
        ''''''
        if not hostname.startswith('[') or not hostname.endswith(']'):
            raise ValueError('Invalid IPv6 address: {}'
                             .format(ascii(hostname)))

        hostname = ipaddress.IPv6Address(hostname[1:-1]).compressed

        return hostname
474260
def normalize(name):
    """"""

    # Name should not contain some specials chars (issue #1068)
    ret = name.replace(':', '')
    ret = ret.replace('%', '')
    ret = ret.replace(' ', '_')

    return ret