<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import httplib
import os
import subprocess
import sys
import time
import urllib2
import which
from collections import OrderedDict


if 'SCCACHE_NAMESERVER' in os.environ:
    from dns.resolver import Resolver, Cache
    resolver = Resolver(configure=False)
    resolver.cache = Cache()
    resolver.nameservers.append(os.environ['SCCACHE_NAMESERVER'])
    def dns_query(host):
        for rr in resolver.query(host):
            return rr.address
else:
    import socket
    def dns_query(host):
        for family, socktype, proto, canonname, sockaddr in \
                socket.getaddrinfo(host, 0):
            return sockaddr[0]


def WrapperFactory(parent_class):
    class WrapperConnection(parent_class):
        def connect(self):
            self.host = dns_query(self.host)
            parent_class.connect(self)

    return WrapperConnection

SCCacheHTTPConnection = WrapperFactory(httplib.HTTPConnection)
SCCacheHTTPSConnection = WrapperFactory(httplib.HTTPSConnection)

class SCCacheHTTPHandler(urllib2.HTTPHandler):
    def http_open(self, req):
        return self.do_open(SCCacheHTTPConnection, req)

class SCCacheHTTPSHandler(urllib2.HTTPSHandler):
    def https_open(self, req):
        return self.do_open(SCCacheHTTPSConnection, req)

urllib2.install_opener(
    urllib2.build_opener(SCCacheHTTPHandler, SCCacheHTTPSHandler))

FILE_TYPES = {
    '.c': 'cpp-output',
    '.cc': 'c++-cpp-output',
    '.cpp': 'c++-cpp-output',
    '.cxx': 'c++-cpp-outout',
}


class Bucket(object):
    def __init__(self):
        self._name = os.environ.get('SCCACHE_BUCKET', '')
        self._status = 0

    def get(self, key):
        self._status = -1
        if not self._name:
            return None<commit_msg>Fix typo<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import httplib
import os
import subprocess
import sys
import time
import urllib2
import which
from collections import OrderedDict


if 'SCCACHE_NAMESERVER' in os.environ:
    from dns.resolver import Resolver, Cache
    resolver = Resolver(configure=False)
    resolver.cache = Cache()
    resolver.nameservers.append(os.environ['SCCACHE_NAMESERVER'])
    def dns_query(host):
        for rr in resolver.query(host):
            return rr.address
else:
    import socket
    def dns_query(host):
        for family, socktype, proto, canonname, sockaddr in \
                socket.getaddrinfo(host, 0):
            return sockaddr[0]


def WrapperFactory(parent_class):
    class WrapperConnection(parent_class):
        def connect(self):
            self.host = dns_query(self.host)
            parent_class.connect(self)

    return WrapperConnection

SCCacheHTTPConnection = WrapperFactory(httplib.HTTPConnection)
SCCacheHTTPSConnection = WrapperFactory(httplib.HTTPSConnection)

class SCCacheHTTPHandler(urllib2.HTTPHandler):
    def http_open(self, req):
        return self.do_open(SCCacheHTTPConnection, req)

class SCCacheHTTPSHandler(urllib2.HTTPSHandler):
    def https_open(self, req):
        return self.do_open(SCCacheHTTPSConnection, req)

urllib2.install_opener(
    urllib2.build_opener(SCCacheHTTPHandler, SCCacheHTTPSHandler))

FILE_TYPES = {
    '.c': 'cpp-output',
    '.cc': 'c++-cpp-output',
    '.cpp': 'c++-cpp-output',
    '.cxx': 'c++-cpp-output',
}


class Bucket(object):
    def __init__(self):
        self._name = os.environ.get('SCCACHE_BUCKET', '')
        self._status = 0

    def get(self, key):
        self._status = -1
        if not self._name:
            return None
{'fraction_non_alphanumeric': 0.10080124063065392, 'fraction_numerical': 0.006720082708710261, 'mean_word_length': 3.2904656319290466, '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': '851883', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1255, 'n_words': 304}