<commit_before>import imp
import json
import os
import sys


class Dot(dict):

    def __init__(self, d):
        super(dict, self).__init__()
        for k, v in iter(d.items()):
            if isinstance(v, dict):
                self[k] = Dot(v)
            else:
                self[k] = v

    def __getattr__(self, attr):
        try:
            return self[attr]
        except KeyError:
            raise AttributeError("'{}'".format(attr))

    __setattr__ = dict.__setitem__

    __delattr__ = dict.__delitem__


class SempaiLoader(object):

    def find_module(self, name, path=None):
        for d in sys.path:
            self.json_path = os.path.join(d, '{}.json'.format(name))
            if os.path.isfile(self.json_path):
                return self
        return None

    def load_module(self, name):
        mod = imp.new_module(name)
        mod.__file__ = self.json_path
        mod.__loader__ = self

        try:
            with open(self.json_path) as f:
                d = json.load(f)
        except ValueError:
            raise ImportError(
                '"{}" does not contain valid json.'.format(self.json_path))
        except:
            raise ImportError(
                'Could not open "{}".'.format(self.json_path))
<commit_msg>Fix python 2.6 default string formatting<commit_after>import imp
import json
import os
import sys


class Dot(dict):

    def __init__(self, d):
        super(dict, self).__init__()
        for k, v in iter(d.items()):
            if isinstance(v, dict):
                self[k] = Dot(v)
            else:
                self[k] = v

    def __getattr__(self, attr):
        try:
            return self[attr]
        except KeyError:
            raise AttributeError("'{}'".format(attr))

    __setattr__ = dict.__setitem__

    __delattr__ = dict.__delitem__


class SempaiLoader(object):

    def find_module(self, name, path=None):
        for d in sys.path:
            self.json_path = os.path.join(d, '{name}.json'.format(name=name))
            if os.path.isfile(self.json_path):
                return self
        return None

    def load_module(self, name):
        mod = imp.new_module(name)
        mod.__file__ = self.json_path
        mod.__loader__ = self

        try:
            with open(self.json_path) as f:
                d = json.load(f)
        except ValueError:
            raise ImportError(
                '"{}" does not contain valid json.'.format(self.json_path))
        except:
            raise ImportError(
                'Could not open "{}".'.format(self.json_path))

{'fraction_non_alphanumeric': 0.10999225406661503, 'fraction_numerical': 0.000774593338497289, 'mean_word_length': 1.762566844919786, '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': '1144719', 'n_tokens_mistral': 795, 'n_tokens_neox': 758, 'n_words': 191}