<commit_before>
import pkgutil
import importlib

import sphinx.application
from docutils.parsers.rst import Directive
from docutils.nodes import paragraph
from docutils.statemachine import StringList

import i3pystatus.core.settings
import i3pystatus.core.modules
from i3pystatus.core.imputil import ClassFinder
from i3pystatus.core.color import ColorRangeModule

IGNORE_MODULES = ("__main__", "core")


def is_module(obj):
    return (isinstance(obj, type)
            and issubclass(obj, i3pystatus.core.settings.SettingsBase)
            and not obj.__module__.startswith("i3pystatus.core."))


def fail_on_missing_dependency_hints(obj, lines):
    # We can automatically check in some cases if we forgot something
    if issubclass(obj, ColorRangeModule):
        if all("`colour`" not in line for line in lines):
            raise ValueError(">>> Module <{}> uses ColorRangeModule and should document it <<<\n"
                             "> Requires the PyPI package `colour`".format(obj.__name__))


def process_docstring(app, what, name, obj, options, lines):
    class Setting:
        doc = ""
        required = False
        default = sentinel = object()
        empty = object()

        def __init__(self, cls, setting):
            if isinstance(setting, tuple):
                self.name = setting[0]
                self.doc = setting[1]
            else:
                self.name = setting

            if setting in cls.required:
                self.required = True
            elif hasattr(cls, self.name):
                default = getattr(cls, self.name)
                if isinstance(default, str) and not len(default)\
                        or default is None:
                    default = self.empty
                self.default = default

        def __str__(self):
            attrs = []
            if self.required:
                attrs.append("required")<commit_msg>That was a little fussy :-)<commit_after>
import pkgutil
import importlib

import sphinx.application
from docutils.parsers.rst import Directive
from docutils.nodes import paragraph
from docutils.statemachine import StringList

import i3pystatus.core.settings
import i3pystatus.core.modules
from i3pystatus.core.imputil import ClassFinder
from i3pystatus.core.color import ColorRangeModule

IGNORE_MODULES = ("__main__", "core")


def is_module(obj):
    return (isinstance(obj, type)
            and issubclass(obj, i3pystatus.core.settings.SettingsBase)
            and not obj.__module__.startswith("i3pystatus.core."))


def fail_on_missing_dependency_hints(obj, lines):
    # We can automatically check in some cases if we forgot something
    if issubclass(obj, ColorRangeModule):
        if all("colour" not in line for line in lines):
            raise ValueError(">>> Module <{}> uses ColorRangeModule and should document it <<<\n"
                             "> Requires the PyPI package ``colour``".format(obj.__name__))


def process_docstring(app, what, name, obj, options, lines):
    class Setting:
        doc = ""
        required = False
        default = sentinel = object()
        empty = object()

        def __init__(self, cls, setting):
            if isinstance(setting, tuple):
                self.name = setting[0]
                self.doc = setting[1]
            else:
                self.name = setting

            if setting in cls.required:
                self.required = True
            elif hasattr(cls, self.name):
                default = getattr(cls, self.name)
                if isinstance(default, str) and not len(default)\
                        or default is None:
                    default = self.empty
                self.default = default

        def __str__(self):
            attrs = []
            if self.required:
                attrs.append("required")
{'fraction_non_alphanumeric': 0.08664921465968586, 'fraction_numerical': 0.004188481675392671, 'mean_word_length': 2.1921470342522973, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1832221', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1002, 'n_words': 302}