<commit_before>import re
import fnmatch
import dns.name
import dns.zone
import dns.query
import dns.exception
import dns.resolver


MAX_NESTED_ALIASES = 10


def sorted_nicely(iter):
    """Sorts strings with embedded numbers in them the way humans would expect.

    http://nedbatchelder.com/blog/200712/human_sorting.html#comments"""

    def tryint(s):
        try:
            return int(s)
        except ValueError:
            return s

    def alphanum_key(s):
        return [tryint(c) for c in re.split('([0-9]+)', s)]

    return sorted(iter, key=alphanum_key)


class HostLookupError(Exception):
    def __init__(self, message):
        self.message = message

    def __str__(self):
        return self.message


def _get_hosts_from_dns(config):
    """Does a DNS zone transfer off the SOA for a given domain to get a list of
    hosts that can be pushed to."""

    try:
        soa_answer = dns.resolver.query(config.dns.domain, "SOA", tcp=True)
        master_answer = dns.resolver.query(soa_answer[0].mname, "A", tcp=True)
        xfr_answer = dns.query.xfr(master_answer[0].address, config.dns.domain)
        zone = dns.zone.from_xfr(xfr_answer)
        return sorted_nicely([name.to_text()
                             for name in zone.nodes.keys()
                             if name != dns.name.empty and not name.is_wild()])
    except dns.exception.DNSException, e:
        raise HostLookupError("host lookup by dns failed: %r" % e)


class HostOrAliasError(Exception):
    def __init__(self, alias, fmt, *args):
        self.alias = alias
        self.fmt = fmt
        self.args = args

    def __str__(self):<commit_msg>Make sure to only look at A records in DNS AXFR.<commit_after>import re
import fnmatch
import dns.name
import dns.zone
import dns.query
import dns.exception
import dns.resolver
import dns.rdtypes


MAX_NESTED_ALIASES = 10


def sorted_nicely(iter):
    """Sorts strings with embedded numbers in them the way humans would expect.

    http://nedbatchelder.com/blog/200712/human_sorting.html#comments"""

    def tryint(s):
        try:
            return int(s)
        except ValueError:
            return s

    def alphanum_key(s):
        return [tryint(c) for c in re.split('([0-9]+)', s)]

    return sorted(iter, key=alphanum_key)


class HostLookupError(Exception):
    def __init__(self, message):
        self.message = message

    def __str__(self):
        return self.message


def _get_hosts_from_dns(config):
    """Does a DNS zone transfer off the SOA for a given domain to get a list of
    hosts that can be pushed to."""

    try:
        soa_answer = dns.resolver.query(config.dns.domain, "SOA", tcp=True)
        master_answer = dns.resolver.query(soa_answer[0].mname, "A", tcp=True)
        xfr_answer = dns.query.xfr(master_answer[0].address, config.dns.domain)
        zone = dns.zone.from_xfr(xfr_answer)
        return sorted_nicely([name.to_text()
                              for name, ttl, rdata in
                              zone.iterate_rdatas("A")])
    except dns.exception.DNSException, e:
        raise HostLookupError("host lookup by dns failed: %r" % e)


class HostOrAliasError(Exception):
    def __init__(self, alias, fmt, *args):
        self.alias = alias
        self.fmt = fmt
        self.args = args

    def __str__(self):
{'fraction_non_alphanumeric': 0.10234798314268513, 'fraction_numerical': 0.007224563515954244, 'mean_word_length': 2.6119565217391303, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '451654', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1060, 'n_words': 287}