<commit_before>import imp
from django.core.management.base import BaseCommand, CommandError


class Command(BaseCommand):
    def handle(self, *app_labels, **options):
        from django.db.models import get_app, get_apps, get_models

        exclude = options.get('exclude', [])

        excluded_apps = [get_app(app_label) for app_label in exclude]

        if len(app_labels) == 0:
            app_list = [app for app in get_apps() if app not in excluded_apps]
        else:
            app_list = [get_app(app_label) for app_label in app_labels]

        for app in app_list:
            name = app.__name__.replace('.models', '')
            app_path = __import__(name, {}, {}, [name.split('.')[-1]]).__path__
            try:
                params = imp.find_module('generator', app_path)
            except ImportError:
                pass
            else:
                generator = imp.load_module(name + '.generator', *params)

                generator.generate()<commit_msg>cleanup<commit_after>import imp
from django.core.management.base import BaseCommand, CommandError

class Command(BaseCommand):
    def handle(self, *app_labels, **options):
        from django.db.models import get_app, get_apps, get_models

        exclude = options.get('exclude', [])

        excluded_apps = [get_app(app_label) for app_label in exclude]

        if len(app_labels) == 0:
            app_list = [app for app in get_apps() if app not in excluded_apps]
        else:
            app_list = [get_app(app_label) for app_label in app_labels]

        for app in app_list:
            name = app.__name__.replace('.models', '')
            app_path = __import__(name, {}, {}, [name.split('.')[-1]]).__path__
            try:
                params = imp.find_module('generator', app_path)
            except ImportError:
                pass
            else:
                generator = imp.load_module(name + '.generator', *params)

                generator.generate()
{'fraction_non_alphanumeric': 0.11037974683544304, 'fraction_numerical': 0.0020253164556962027, 'mean_word_length': 2.218241042345277, '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': '3617207', 'n_tokens_mistral': 564, 'n_tokens_neox': 544, 'n_words': 139}