<commit_before>import os
from couchdbkit.ext.django.loading import get_db
# corehq dependency is simplest of a few annoying options
# - move this code into corehq
# - extract corehq.preindex into its own project
# - be ok with intentionally introducing this dependency
#   for something that's pretty bound to our specific deploy workflow
from corehq.preindex import PreindexPlugin
from dimagi.utils.couch.sync_docs import DesignInfo
from pillowtop.utils import get_all_pillow_classes


class FluffPreindexPlugin(PreindexPlugin):

    def get_designs(self):
        designs = []
        for pillow in get_all_pillow_classes():
            if hasattr(pillow, 'indicator_class'):
                app_label = pillow.indicator_class._meta.app_label
                designs.append(DesignInfo(
                    app_label=self.app_label,
                    db=get_db(app_label),
                    design_path=os.path.join(self.dir, "_design")
                ))
        return designs


FluffPreindexPlugin.register('fluff', __file__)
<commit_msg>change FluffPreindexPlugin to comply with refactor<commit_after>import os
from couchdbkit.ext.django.loading import get_db
# corehq dependency is simplest of a few annoying options
# - move this code into corehq
# - extract corehq.preindex into its own project
# - be ok with intentionally introducing this dependency
#   for something that's pretty bound to our specific deploy workflow
from corehq.preindex import PreindexPlugin
from dimagi.utils.couch.sync_docs import DesignInfo
from pillowtop.utils import get_all_pillow_classes


class FluffPreindexPlugin(PreindexPlugin):
    def __init__(self, app_label, file):
        self.app_label = app_label
        self.dir = os.path.abspath(os.path.dirname(file))

    def get_designs(self):
        designs = []
        for pillow in get_all_pillow_classes():
            if hasattr(pillow, 'indicator_class'):
                app_label = pillow.indicator_class._meta.app_label
                designs.append(DesignInfo(
                    app_label=self.app_label,
                    db=get_db(app_label),
                    design_path=os.path.join(self.dir, "_design")
                ))
        return designs


FluffPreindexPlugin.register('fluff', __file__)

{'fraction_non_alphanumeric': 0.06937693327441449, 'fraction_numerical': 0.0, 'mean_word_length': 2.9442508710801394, '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': '5591657', 'n_tokens_mistral': 650, 'n_tokens_neox': 627, 'n_words': 169}