<commit_before># -*- coding: utf-8 -*-
import bot
import socket


def is_valid_ipv4_address(address):
    try:
        socket.inet_pton(socket.AF_INET, address)
    except AttributeError:  # no inet_pton here, sorry
        try:
            socket.inet_aton(address)
        except socket.error:
            return False
        return address.count('.') == 3
    except socket.error:  # not a valid address
        return False

    return True


def is_valid_ipv6_address(address):
    try:
        socket.inet_pton(socket.AF_INET6, address)
    except socket.error:  # not a valid address
        return False
    return True


def hostinfo(http, inhost, l='en', rdns=False):
    ip = inhost
    host = inhost
    try:
        if not is_valid_ipv6_address(ip) and not is_valid_ipv4_address(ip):
            r = http.request(
                "http://api.statdns.com/%s/a" % inhost, timeout=2).json()
            if 'error' not in r and r['answer']:
                ip = r['answer'][0]['rdata']
        if rdns:
            r = http.request(
                "http://api.statdns.com/x/%s" % ip, timeout=2).json()
            if 'error' not in r and r['answer']:
                host = r['answer'][0]['rdata'].rstrip('.')
    except ValueError:
        pass
    except http.Error:
        pass<commit_msg>fix geoip<commit_after># -*- coding: utf-8 -*-
import bot
import socket


def is_valid_ipv4_address(address):
    try:
        socket.inet_pton(socket.AF_INET, address)
    except AttributeError:  # no inet_pton here, sorry
        try:
            socket.inet_aton(address)
        except socket.error:
            return False
        return address.count('.') == 3
    except socket.error:  # not a valid address
        return False

    return True


def is_valid_ipv6_address(address):
    try:
        socket.inet_pton(socket.AF_INET6, address)
    except socket.error:  # not a valid address
        return False
    return True


def hostinfo(http, inhost, l='en', rdns=False):
    ip = inhost
    host = inhost
    try:
        if not is_valid_ipv6_address(ip) and not is_valid_ipv4_address(ip):
            ip = ""
            r = http.request(
                "http://api.statdns.com/%s/a" % inhost, timeout=2).json()
            if 'error' not in r and r['answer']:
                ip = r['answer'][0]['rdata']
                host = ip
        if rdns and ip:
            r = http.request(
                "http://api.statdns.com/x/%s" % ip, timeout=2).json()
            if 'error' not in r and r['answer']:
                host = r['answer'][0]['rdata'].rstrip('.')
    except ValueError:
        pass
    except http.Error:
        pass
    if not ip:
        return {}
{'fraction_non_alphanumeric': 0.11933085501858737, 'fraction_numerical': 0.008178438661710037, 'mean_word_length': 1.9218241042345277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321198', 'n_tokens_mistral': 855, 'n_tokens_neox': 848, 'n_words': 217}