<commit_before>
from OpenSSL.SSL import Context, TLSv1_METHOD
from twisted.internet.ssl import ContextFactory
from txsni.only_noticed_pypi_pem_after_i_wrote_this import (
    certificateOptionsFromPileOfPEM
)

class SNIMap(ContextFactory, object):
    def __init__(self, mapping):
        self.mapping = mapping
        self.context = Context(TLSv1_METHOD)
        self.context.set_tlsext_servername_callback(
            self.selectContext
        )

    def getContext(self):
        return self.context

    def selectContext(self, connection):
        connection.set_context(
            self.mapping[connection.get_servername()]
            .getContext()
        )



class HostDirectoryMap(object):
    def __init__(self, directoryPath):
        self.directoryPath = directoryPath

<commit_msg>Provide a way to set a default context.<commit_after>
from OpenSSL.SSL import Context, TLSv1_METHOD
from twisted.internet.ssl import ContextFactory
from txsni.only_noticed_pypi_pem_after_i_wrote_this import (
    certificateOptionsFromPileOfPEM
)

class SNIMap(ContextFactory, object):
    def __init__(self, mapping):
        self.mapping = mapping
        try:
            self.context = self.mapping['DEFAULT']
        except KeyError:
            self.context = Context(TLSv1_METHOD)
        self.context.set_tlsext_servername_callback(
            self.selectContext
        )

    def getContext(self):
        return self.context

    def selectContext(self, connection):
        connection.set_context(
            self.mapping[connection.get_servername()]
            .getContext()
        )



class HostDirectoryMap(object):
    def __init__(self, directoryPath):
        self.directoryPath = directoryPath


{'fraction_non_alphanumeric': 0.07329842931937172, 'fraction_numerical': 0.002326934264107039, 'mean_word_length': 2.972286374133949, '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': '3776869', 'n_tokens_mistral': 493, 'n_tokens_neox': 481, 'n_words': 98}