<commit_before>import logging

from adhocracy import model
from pylons import config

log = logging.getLogger(__name__)


class InstanceDiscriminatorMiddleware(object):

    def __init__(self, app, domain):
        self.app = app
        self.domain = domain
        log.debug("Host name: %s." % domain)

    def __call__(self, environ, start_response):
        environ['adhocracy.domain'] = self.domain
        instance_key = config.get('adhocracy.instance')
        if instance_key is None:
            path = environ.get('PATH_INFO', '')
            if path.startswith('/i/'):
                instance_key = path.split('/')[2]
                environ['PATH_INFO'] = path[len('/i/' + instance_key):]
            else:<commit_msg>Be more deterministic in the discriminator<commit_after>import logging

from adhocracy import model
from pylons import config
from paste.deploy.converters import asbool

log = logging.getLogger(__name__)


class InstanceDiscriminatorMiddleware(object):

    def __init__(self, app, domain):
        self.app = app
        self.domain = domain
        log.debug("Host name: %s." % domain)

    def __call__(self, environ, start_response):
        environ['adhocracy.domain'] = self.domain
        instance_key = config.get('adhocracy.instance')
        if instance_key is None:
            if asbool(config.get('adhocracy.urls_without_hostname', 'false')):
                path = environ.get('PATH_INFO', '')
                if path.startswith('/i/'):
                    instance_key = path.split('/')[2]
                    environ['PATH_INFO'] = path[len('/i/' + instance_key):]
            else:
{'fraction_non_alphanumeric': 0.1190914671577655, 'fraction_numerical': 0.0012277470841006752, 'mean_word_length': 2.5824175824175826, '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': '3001979', 'n_tokens_mistral': 474, 'n_tokens_neox': 459, 'n_words': 107}