<commit_before>import json, urllib2, logging

class MalformedJSON(Exception):
    pass

class Server:
    """
    A connection to a DNSChain server.
    """

    def __init__(self, addr, fingerprint, http_host_header='namecoin.dns'):
        """
        Store configuration for requests to a DNSChain server.

        @param addr: The address of the trusted DNSChain server (IP or hostname)
        TODO: May need port here?
        @param fingerprint: The key fingerprint of the DNSChain server, for connection authorization
        """

        self.addr = addr
        self.fingerprint = fingerprint
        self.headers = {'Host': http_host_header}#Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    def lookup(self, name):
        """
        Looks up a name from the DNSChain server. Throws exception if the
        data is not valid JSON or if the namecoin entry does not exist in the
        blockchain.

        @param name: The name to lookup, e.g. 'id/dionyziz'
        """
        partition_tuple = name.partition('/')
        urlunsafe_name = partition_tuple[2]
        urlsafe_name = urllib2.quote(urlunsafe_name, safe="") #a url path _component_.
        url_path = '%s/%s' % (partition_tuple[0], urlsafe_name)
        full_url = "http://%s/%s" % (self.addr, url_path)<commit_msg>Add host override to lookup<commit_after>import json, urllib2, logging

class MalformedJSON(Exception):
    pass

class Server:
    """
    A connection to a DNSChain server.
    """

    def __init__(self, addr, fingerprint, http_host_header='namecoin.dns'):
        """
        Store configuration for requests to a DNSChain server.

        @param addr: The address of the trusted DNSChain server (IP or hostname)
        TODO: May need port here?
        @param fingerprint: The key fingerprint of the DNSChain server, for connection authorization
        """

        self.addr = addr
        self.fingerprint = fingerprint
        self.headers = {'Host': http_host_header}#Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    def lookup(self, name, host_override=None):
        """
        Looks up a name from the DNSChain server. Throws exception if the
        data is not valid JSON or if the namecoin entry does not exist in the
        blockchain.

        @param name: The name to lookup, e.g. 'id/dionyziz'
        """
        if host_override is not None:
            self.headers['Host'] = host_override
        partition_tuple = name.partition('/')
        urlunsafe_name = partition_tuple[2]
        urlsafe_name = urllib2.quote(urlunsafe_name, safe="") #a url path _component_.
        url_path = '%s/%s' % (partition_tuple[0], urlsafe_name)
        full_url = "http://%s/%s" % (self.addr, url_path)
{'fraction_non_alphanumeric': 0.09828279137742053, 'fraction_numerical': 0.010960906101571063, 'mean_word_length': 2.6458055925432755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4694737', 'n_tokens_mistral': 833, 'n_tokens_neox': 789, 'n_words': 257}