<commit_before>

def downgrade_wsgi_ux_to_1x(environ):
    """Return a new environ dict for WSGI 1.x from the given WSGI u.x environ."""
    env1x = {}

    url_encoding = environ[native_to_unicode('wsgi.url_encoding')]
    for k, v in list(environ.items()):
        if k in [native_to_unicode('PATH_INFO'), native_to_unicode('SCRIPT_NAME'), native_to_unicode('QUERY_STRING')]:
            v = v.encode(url_encoding)
        elif isinstance(v, unicodestr):
            v = v.encode('ISO-8859-1')
        env1x[k.encode('ISO-8859-1')] = v

    return env1x


<commit_msg>added urljoin utility<commit_after>from pecan_mount._compat import native_to_unicode, unicodestr


def downgrade_wsgi_ux_to_1x(environ):
    """
    Return a new environ dict for WSGI 1.x from the given WSGI u.x
    environ.
    """
    env1x = {}

    url_encoding = environ[native_to_unicode('wsgi.url_encoding')]
    for k, v in list(environ.items()):
        if k in [native_to_unicode('PATH_INFO'),
                 native_to_unicode('SCRIPT_NAME'),
                 native_to_unicode('QUERY_STRING')]:
            v = v.encode(url_encoding)
        elif isinstance(v, unicodestr):
            v = v.encode('ISO-8859-1')
        env1x[k.encode('ISO-8859-1')] = v

    return env1x


def urljoin(*atoms):
    """Return the given path \*atoms, joined into a single URL.

    This will correctly join a SCRIPT_NAME and PATH_INFO into the
    original URL, even if either atom is blank.
    """
    url = "/".join([x for x in atoms if x])
    while "//" in url:
        url = url.replace("//", "/")
    # Special-case the final url of "", and return "/" instead.
    return url or "/"
{'fraction_non_alphanumeric': 0.1256797583081571, 'fraction_numerical': 0.01812688821752266, 'mean_word_length': 2.7551020408163267, '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': '6395077', 'n_tokens_mistral': 589, 'n_tokens_neox': 556, 'n_words': 144}